knex/test/unit/util/comma-no-paren-regex.js
Rijk van Zanten 9692e36561
Add primary/foreign support to SQLite on alterTable (#4162)
Co-authored-by: Igor Savin <iselwin@gmail.com>
2020-12-26 19:10:40 +02:00

19 lines
566 B
JavaScript

const { COMMA_NO_PAREN_REGEX } = require('../../../lib/constants');
const { expect } = require('chai');
describe('COMMA_NO_PAREN Regex', () => {
it('Splits string on commas, excluding those wrapped in parentheses', () => {
const source = `id integer, external_id integer, name string, body text, PRIMARY KEY (id, external_id)`;
const result = source.split(COMMA_NO_PAREN_REGEX);
expect(result).to.eql([
'id integer',
'external_id integer',
'name string',
'body text',
'PRIMARY KEY (id, external_id)',
]);
});
});