@databases/split-sql-query
Advanced tools
Comparing version 1.0.3 to 1.0.4-canary-2376
@@ -6,15 +6,15 @@ "use strict"; | ||
test('hasValues', () => { | ||
expect(__1.hasValues(sql_1.default `SELECT * FROM ${sql_1.default.ident('my_table')}`)).toBe(false); | ||
expect(__1.hasValues(sql_1.default `SELECT * FROM ${sql_1.default.ident('my_table')} WHERE id = ${42}`)).toBe(true); | ||
expect((0, __1.hasValues)((0, sql_1.default) `SELECT * FROM ${sql_1.default.ident('my_table')}`)).toBe(false); | ||
expect((0, __1.hasValues)((0, sql_1.default) `SELECT * FROM ${sql_1.default.ident('my_table')} WHERE id = ${42}`)).toBe(true); | ||
}); | ||
test('hasSemicolonBeforeEnd', () => { | ||
expect(__1.hasSemicolonBeforeEnd(sql_1.default `SELECT * FROM ${sql_1.default.ident('my_table')}`)).toBe(false); | ||
expect(__1.hasSemicolonBeforeEnd(sql_1.default `SELECT * FROM ${sql_1.default.ident('my_table')} WHERE id = ${42};`)).toBe(false); | ||
expect(__1.hasSemicolonBeforeEnd(sql_1.default ` | ||
expect((0, __1.hasSemicolonBeforeEnd)((0, sql_1.default) `SELECT * FROM ${sql_1.default.ident('my_table')}`)).toBe(false); | ||
expect((0, __1.hasSemicolonBeforeEnd)((0, sql_1.default) `SELECT * FROM ${sql_1.default.ident('my_table')} WHERE id = ${42};`)).toBe(false); | ||
expect((0, __1.hasSemicolonBeforeEnd)((0, sql_1.default) ` | ||
SELECT * FROM ${sql_1.default.ident('my_table')} WHERE id = ${42}; | ||
`)).toBe(false); | ||
expect(__1.hasSemicolonBeforeEnd(sql_1.default ` | ||
expect((0, __1.hasSemicolonBeforeEnd)((0, sql_1.default) ` | ||
SELECT * FROM ${sql_1.default.ident('my_table')} WHERE val = ${'foo;bar'}; | ||
`)).toBe(false); | ||
expect(__1.hasSemicolonBeforeEnd(sql_1.default ` | ||
expect((0, __1.hasSemicolonBeforeEnd)((0, sql_1.default) ` | ||
INSERT INTO ${sql_1.default.ident('my_table')} (id, value) VALUES (42, 'foo'); | ||
@@ -31,3 +31,3 @@ SELECT * FROM ${sql_1.default.ident('my_table')} WHERE id = ${42}; | ||
function doesNotSplit(query) { | ||
const split = __1.default(query); | ||
const split = (0, __1.default)(query); | ||
expect(split.map((q) => q.format(testFormatter).text)).toEqual([ | ||
@@ -39,11 +39,11 @@ query.format(testFormatter).text, | ||
test('splitSqlQuery', () => { | ||
doesNotSplit(sql_1.default `SELECT * FROM ${sql_1.default.ident('my_table')}`); | ||
doesNotSplit(sql_1.default `SELECT * FROM ${sql_1.default.ident('my_table')} WHERE id = ${42};`); | ||
doesNotSplit(sql_1.default ` | ||
doesNotSplit((0, sql_1.default) `SELECT * FROM ${sql_1.default.ident('my_table')}`); | ||
doesNotSplit((0, sql_1.default) `SELECT * FROM ${sql_1.default.ident('my_table')} WHERE id = ${42};`); | ||
doesNotSplit((0, sql_1.default) ` | ||
SELECT * FROM ${sql_1.default.ident('my_table')} WHERE id = ${42}; | ||
`); | ||
doesNotSplit(sql_1.default ` | ||
doesNotSplit((0, sql_1.default) ` | ||
SELECT * FROM ${sql_1.default.ident('my_table')} WHERE val = ${'foo;bar'}; | ||
`); | ||
doesNotSplit(sql_1.default ` | ||
doesNotSplit((0, sql_1.default) ` | ||
SELECT * FROM ${sql_1.default.ident('my_table')} -- semicolons; in; comments; don't count; | ||
@@ -53,12 +53,12 @@ WHERE val = 'foo;bar' | ||
`); | ||
expect(__1.default(sql_1.default ` | ||
expect((0, __1.default)((0, sql_1.default) ` | ||
INSERT INTO ${sql_1.default.ident('my_table')} (id, value) VALUES (42, 'foo'); | ||
SELECT * FROM ${sql_1.default.ident('my_table')} WHERE id = ${42}; | ||
`).map((q) => q.format(testFormatter))).toEqual([ | ||
sql_1.default `INSERT INTO ${sql_1.default.ident('my_table')} (id, value) VALUES (42, 'foo')`, | ||
sql_1.default `SELECT * FROM ${sql_1.default.ident('my_table')} WHERE id = ${42}`, | ||
(0, sql_1.default) `INSERT INTO ${sql_1.default.ident('my_table')} (id, value) VALUES (42, 'foo')`, | ||
(0, sql_1.default) `SELECT * FROM ${sql_1.default.ident('my_table')} WHERE id = ${42}`, | ||
].map((q) => q.format(testFormatter))); | ||
}); | ||
test('regression - 1', () => { | ||
expect(__1.default(sql_1.default ` | ||
expect((0, __1.default)((0, sql_1.default) ` | ||
CREATE DOMAIN custom_types.email AS TEXT CHECK (VALUE ~ '^.+@.+$'); | ||
@@ -87,3 +87,3 @@ CREATE TYPE custom_types.currency AS ENUM('USD', 'GBP'); | ||
test('regression - 2', () => { | ||
expect(__1.default(sql_1.default ` | ||
expect((0, __1.default)((0, sql_1.default) ` | ||
CREATE OR REPLACE FUNCTION update_updated_at_column() | ||
@@ -99,4 +99,4 @@ RETURNS TRIGGER AS $$ | ||
`).length).toBe(2); | ||
expect(__1.default(sql_1.default `$SomeTag$Dianne's$WrongTag$;$some non tag an$identifier;; horse$SomeTag$;$SomeTag$Dianne's horse$SomeTag$`).length).toBe(2); | ||
expect((0, __1.default)((0, sql_1.default) `$SomeTag$Dianne's$WrongTag$;$some non tag an$identifier;; horse$SomeTag$;$SomeTag$Dianne's horse$SomeTag$`).length).toBe(2); | ||
}); | ||
//# sourceMappingURL=index.test.js.map |
@@ -213,2 +213,7 @@ "use strict"; | ||
exports.default = splitSqlQuery; | ||
module.exports = Object.assign(splitSqlQuery, { | ||
default: splitSqlQuery, | ||
hasValues, | ||
hasSemicolonBeforeEnd, | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@databases/split-sql-query", | ||
"version": "1.0.3", | ||
"version": "1.0.4-canary-2376", | ||
"description": "", | ||
@@ -8,3 +8,3 @@ "main": "./lib/index.js", | ||
"devDependencies": { | ||
"@databases/sql": "^3.1.0" | ||
"@databases/sql": "3.3.0" | ||
}, | ||
@@ -11,0 +11,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
328
51049
1