pqb 0.11.24 → 0.11.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -124,7 +124,7 @@ class ColumnType extends orchidCore.ColumnTypeBase {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
const
|
|
127
|
+
const used = [];
|
|
128
128
|
const getRaw = (raw, valuesArray) => {
|
|
129
129
|
if (!raw.__values) {
|
|
130
130
|
return raw.__raw;
|
|
@@ -132,21 +132,29 @@ const getRaw = (raw, valuesArray) => {
|
|
|
132
132
|
const arr = raw.__raw.split("'");
|
|
133
133
|
const values = raw.__values;
|
|
134
134
|
const len = arr.length;
|
|
135
|
-
|
|
135
|
+
used.length = 0;
|
|
136
136
|
for (let i = 0; i < len; i += 2) {
|
|
137
|
-
arr[i] = arr[i].replace(
|
|
137
|
+
arr[i] = arr[i].replace(/\$\$?(\w+)/g, (match, key) => {
|
|
138
138
|
const value = values[key];
|
|
139
139
|
if (value === void 0) {
|
|
140
140
|
throw new Error(`Query variable \`${key}\` is not provided`);
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
used.push(key);
|
|
143
|
+
if (match.length - key.length === 2) {
|
|
144
|
+
if (typeof value !== "string") {
|
|
145
|
+
throw new Error(
|
|
146
|
+
`Expected string value for $$${key} SQL keyword, got ${typeof value}`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
return `"${value.replace('"', '""').replace(".", '"."')}"`;
|
|
150
|
+
}
|
|
143
151
|
valuesArray.push(value);
|
|
144
152
|
return `$${valuesArray.length}`;
|
|
145
153
|
});
|
|
146
154
|
}
|
|
147
|
-
if (
|
|
155
|
+
if (used.length > 0 && used.length < Object.keys(values).length) {
|
|
148
156
|
for (const key in values) {
|
|
149
|
-
if (!
|
|
157
|
+
if (!used.includes(key)) {
|
|
150
158
|
throw new Error(`Query variable \`${key}\` is unused`);
|
|
151
159
|
}
|
|
152
160
|
}
|