live-query-mysql
Advanced tools
Comparing version 1.0.0 to 1.0.1
export * from "./LiveQuery"; | ||
export { enableLiveQueries, resetLiveQueriesTracks, getQueryDataTrack } from "./tracker"; | ||
export { setLiveQueryOptions } from "./options"; |
@@ -13,3 +13,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getQueryDataTrack = exports.resetLiveQueriesTracks = exports.enableLiveQueries = void 0; | ||
exports.setLiveQueryOptions = exports.getQueryDataTrack = exports.resetLiveQueriesTracks = exports.enableLiveQueries = void 0; | ||
__exportStar(require("./LiveQuery"), exports); | ||
@@ -20,2 +20,4 @@ var tracker_1 = require("./tracker"); | ||
Object.defineProperty(exports, "getQueryDataTrack", { enumerable: true, get: function () { return tracker_1.getQueryDataTrack; } }); | ||
var options_1 = require("./options"); | ||
Object.defineProperty(exports, "setLiveQueryOptions", { enumerable: true, get: function () { return options_1.setLiveQueryOptions; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -38,4 +38,4 @@ "use strict"; | ||
case "string": | ||
if (node.value.startsWith(placeholderPrefix)) { | ||
const placeholderIndex = +node.value.substring(placeholderPrefix.length); | ||
if (node.value.startsWith(stringPlaceholderPrefix)) { | ||
const placeholderIndex = +node.value.substring(stringPlaceholderPrefix.length); | ||
if (placeholderIndex >= params.length) | ||
@@ -47,2 +47,9 @@ throw new Error("Query has more placeholders than params"); | ||
case "number": | ||
if (("" + node.value).startsWith(numberPlaceholderPrefix)) { | ||
const placeholderIndex = +("" + node.value).substring(numberPlaceholderPrefix.length); | ||
if (placeholderIndex >= params.length) | ||
throw new Error("Query has more placeholders than params"); | ||
return () => params[placeholderIndex]; | ||
} | ||
return () => node.value; | ||
case "single_quote_string": | ||
@@ -130,7 +137,19 @@ case "bool": | ||
let r = ""; | ||
let lastPart = ""; | ||
// some params can only be numbers | ||
function isNumberPlaceholder() { | ||
const s = lastPart.toLowerCase(); | ||
return s.indexOf("limit") >= 0 || s.indexOf("offset") >= 0; | ||
} | ||
s.split("?").forEach((part, i) => { | ||
if (i > 0) { | ||
r += `"${placeholderPrefix}${i - 1}"`; | ||
if (isNumberPlaceholder()) { | ||
r += `${numberPlaceholderPrefix}${i - 1}`; | ||
} | ||
else { | ||
r += `"${stringPlaceholderPrefix}${i - 1}"`; | ||
} | ||
} | ||
r += part; | ||
lastPart = part; | ||
}); | ||
@@ -140,3 +159,4 @@ return r; | ||
exports.wrapPlaceholders = wrapPlaceholders; | ||
const placeholderPrefix = "??"; | ||
const stringPlaceholderPrefix = "??"; | ||
const numberPlaceholderPrefix = "77700000"; | ||
//# sourceMappingURL=trackExpression.js.map |
{ | ||
"name": "live-query-mysql", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"main": "dist/index.js", | ||
@@ -25,3 +25,3 @@ "types": "dist/index.d.ts", | ||
"loglevel": "^1.7.0", | ||
"node-sql-parser": "^3.1.0" | ||
"node-sql-parser": "^3.6.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
26792
369
Updatednode-sql-parser@^3.6.0