@simplehealth/filterql
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -0,1 +1,6 @@ | ||
# v0.2.3 | ||
- Fix: properly quote MySQL identifiers (table and/or column names) | ||
- Fix: `OR()` signature is now consistent with `AND()` | ||
# v0.2.2 | ||
@@ -2,0 +7,0 @@ |
{ | ||
"name": "@simplehealth/filterql", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "The FilterQL mini-language.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -34,11 +34,2 @@ "use strict"; | ||
var holeRegex = /\?\??/g; | ||
var fieldRegex = /^([a-z_]+)([.][a-z_]+)?$/i; | ||
function ensureField(field) { | ||
if (!fieldRegex.test(field)) { | ||
throw new Error("Not a valid field name: ".concat(JSON.stringify(field))); | ||
} | ||
return field; | ||
} | ||
/** | ||
@@ -52,3 +43,2 @@ * Core building block for all SQL conditions. Produces a raw SQL / params | ||
function RAW(sqlExpr, params) { | ||
@@ -75,4 +65,4 @@ var match = sqlExpr.match(holeRegex); | ||
return { | ||
sqlExpr: "".concat(ensureField(field), " IS NULL"), | ||
params: [] | ||
sqlExpr: '?? IS NULL', | ||
params: [field] | ||
}; | ||
@@ -83,4 +73,4 @@ } | ||
return { | ||
sqlExpr: "".concat(ensureField(field), " IS NOT NULL"), | ||
params: [] | ||
sqlExpr: '?? IS NOT NULL', | ||
params: [field] | ||
}; | ||
@@ -94,11 +84,11 @@ } | ||
// NOT safely. | ||
"".concat(ensureField(field), " <=> ?"), [value]); | ||
'?? <=> ?', [field, value]); | ||
} | ||
function IN(field, values) { | ||
return values.length > 0 ? RAW("".concat(ensureField(field), " IN (?)"), [values]) : FALSE; | ||
return values.length > 0 ? RAW('?? IN (?)', [field, values]) : FALSE; | ||
} | ||
function GTE(field, value) { | ||
return RAW("".concat(ensureField(field), " >= ?"), [value]); | ||
return RAW('?? >= ?', [field, value]); | ||
} | ||
@@ -119,3 +109,3 @@ | ||
function INSTR(field, value) { | ||
return RAW("INSTR(".concat(ensureField(field), ", ?)"), [value]); | ||
return RAW('INSTR(??, ?)', [field, value]); | ||
} | ||
@@ -155,3 +145,7 @@ | ||
function OR(conditions) { | ||
function OR() { | ||
for (var _len2 = arguments.length, conditions = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
conditions[_key2] = arguments[_key2]; | ||
} | ||
if (conditions.length === 0) { | ||
@@ -158,0 +152,0 @@ return FALSE; |
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
52005
848