@sqb/mssql 6.0.2 → 6.0.4
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/mssql-connection.js +23 -5
- package/package.json +4 -4
package/mssql-connection.js
CHANGED
|
@@ -31,7 +31,7 @@ const typeNameMap = {
|
|
|
31
31
|
VarBinary: { dataType: 'VARBINARY', jsType: 'Buffer' },
|
|
32
32
|
Image: { dataType: 'IMAGE', jsType: 'Buffer' },
|
|
33
33
|
};
|
|
34
|
-
const NAMED_PARAM_PATTERN =
|
|
34
|
+
const NAMED_PARAM_PATTERN = /^( *):([a-zA-Z_]\w*)$/;
|
|
35
35
|
export class MssqlConnection {
|
|
36
36
|
intlcon;
|
|
37
37
|
_transaction;
|
|
@@ -205,11 +205,29 @@ export class MssqlConnection {
|
|
|
205
205
|
});
|
|
206
206
|
let token;
|
|
207
207
|
let out = '';
|
|
208
|
-
|
|
208
|
+
// quotes:true hands back an entire string/double-quoted-identifier
|
|
209
|
+
// literal as one token, so a ":name" occurring inside one never
|
|
210
|
+
// matches the anchored NAMED_PARAM_PATTERN at all. T-SQL's [bracket]
|
|
211
|
+
// identifier quoting isn't a "quote" character the tokenizer knows
|
|
212
|
+
// about though (brackets:false), so "[col:name]" comes back as three
|
|
213
|
+
// separate tokens ("[col", ":name", "]") - track bracket state
|
|
214
|
+
// explicitly so a ":name" inside one isn't mistaken for a param.
|
|
215
|
+
let inBracket = false;
|
|
209
216
|
while ((token = tokenizer.next())) {
|
|
210
|
-
|
|
211
|
-
if (
|
|
212
|
-
|
|
217
|
+
const trimmed = token.trim();
|
|
218
|
+
if (inBracket) {
|
|
219
|
+
if (trimmed.includes(']'))
|
|
220
|
+
inBracket = false;
|
|
221
|
+
}
|
|
222
|
+
else if (trimmed.startsWith('[')) {
|
|
223
|
+
inBracket = true;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
const m = NAMED_PARAM_PATTERN.exec(token);
|
|
227
|
+
if (m) {
|
|
228
|
+
const [, leading, name] = m;
|
|
229
|
+
token = leading + '@' + name;
|
|
230
|
+
}
|
|
213
231
|
}
|
|
214
232
|
out += token;
|
|
215
233
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/mssql",
|
|
3
3
|
"description": "SQB adapter for the mssql (tedious) driver",
|
|
4
|
-
"version": "6.0.
|
|
4
|
+
"version": "6.0.4",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"dependencies": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"tslib": "^2.8.1"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@sqb/builder": "^6.0.
|
|
13
|
-
"@sqb/connect": "^6.0.
|
|
14
|
-
"@sqb/mssql-dialect": "^6.0.
|
|
12
|
+
"@sqb/builder": "^6.0.4",
|
|
13
|
+
"@sqb/connect": "^6.0.4",
|
|
14
|
+
"@sqb/mssql-dialect": "^6.0.4",
|
|
15
15
|
"mssql": "^11.0.0 || ^12.0.0"
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|