orange-orm 4.7.5-beta.1 → 4.7.6
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/dist/index.mjs +12 -12
- package/docs/changelog.md +2 -0
- package/package.json +1 -1
- package/src/mssql/wrapQuery.js +12 -12
package/dist/index.mjs
CHANGED
|
@@ -17444,6 +17444,7 @@ function requireWrapQuery$2 () {
|
|
|
17444
17444
|
function runQuery(query, onCompleted) {
|
|
17445
17445
|
var params = query.parameters;
|
|
17446
17446
|
var sql = query.sql();
|
|
17447
|
+
log.emitQuery({ sql, parameters: params });
|
|
17447
17448
|
|
|
17448
17449
|
const replacements = [];
|
|
17449
17450
|
const parametersToRemove = [];
|
|
@@ -17451,7 +17452,6 @@ function requireWrapQuery$2 () {
|
|
|
17451
17452
|
|
|
17452
17453
|
if (engine === 'sap') {
|
|
17453
17454
|
const sap = connection.msnodesqlv8;
|
|
17454
|
-
// Helper function to check for non-ASCII UTF-8 characters
|
|
17455
17455
|
|
|
17456
17456
|
// Check if this is a stored procedure call
|
|
17457
17457
|
const isStoredProcCall = /EXECUTE\s+/i.test(sql) || /EXEC\s+/i.test(sql);
|
|
@@ -17462,17 +17462,19 @@ function requireWrapQuery$2 () {
|
|
|
17462
17462
|
const parameter = params[i];
|
|
17463
17463
|
|
|
17464
17464
|
if (typeof parameter === 'string') {
|
|
17465
|
-
|
|
17465
|
+
const paramLength = parameter.length;
|
|
17466
|
+
const byteLength = Buffer.from(parameter, 'utf8').length;
|
|
17466
17467
|
|
|
17468
|
+
if (hasNonAsciiCharacters(parameter)) {
|
|
17467
17469
|
const hexValue = stringToHex(parameter);
|
|
17468
17470
|
|
|
17469
17471
|
if (isStoredProcCall) {
|
|
17470
|
-
// For stored procedures, create a variable
|
|
17472
|
+
// For stored procedures, create a variable with exact lengths
|
|
17471
17473
|
const varName = `@hex_param_${i}`;
|
|
17472
|
-
const convertClause = `CONVERT(VARCHAR(
|
|
17474
|
+
const convertClause = `CONVERT(VARCHAR(${paramLength}), CONVERT(VARBINARY(${byteLength}), 0x${hexValue}))`;
|
|
17473
17475
|
|
|
17474
17476
|
hexVariables.push({
|
|
17475
|
-
declaration: `DECLARE ${varName} VARCHAR(
|
|
17477
|
+
declaration: `DECLARE ${varName} VARCHAR(${paramLength})`,
|
|
17476
17478
|
assignment: `SET ${varName} = ${convertClause}`
|
|
17477
17479
|
});
|
|
17478
17480
|
|
|
@@ -17481,17 +17483,18 @@ function requireWrapQuery$2 () {
|
|
|
17481
17483
|
replacement: varName
|
|
17482
17484
|
});
|
|
17483
17485
|
} else {
|
|
17484
|
-
// For regular queries, use inline conversion
|
|
17485
|
-
const convertClause = `CONVERT(VARCHAR(
|
|
17486
|
+
// For regular queries, use inline conversion with exact lengths
|
|
17487
|
+
const convertClause = `CONVERT(VARCHAR(${paramLength}), CONVERT(VARBINARY(${byteLength}), 0x${hexValue}))`;
|
|
17486
17488
|
replacements.push({
|
|
17487
17489
|
index: i,
|
|
17488
17490
|
replacement: convertClause
|
|
17489
17491
|
});
|
|
17490
17492
|
}
|
|
17491
17493
|
parametersToRemove.push(i);
|
|
17494
|
+
} else {
|
|
17495
|
+
// For ASCII strings, use VarChar with exact byte length
|
|
17496
|
+
params[i] = sap.VarChar(parameter, byteLength);
|
|
17492
17497
|
}
|
|
17493
|
-
else
|
|
17494
|
-
params[i] = sap.VarChar(parameter);
|
|
17495
17498
|
}
|
|
17496
17499
|
}
|
|
17497
17500
|
|
|
@@ -17535,8 +17538,6 @@ function requireWrapQuery$2 () {
|
|
|
17535
17538
|
});
|
|
17536
17539
|
}
|
|
17537
17540
|
|
|
17538
|
-
log.emitQuery({ sql, parameters: params });
|
|
17539
|
-
|
|
17540
17541
|
runOriginalQuery.call(connection, sql, params, onInnerCompleted);
|
|
17541
17542
|
let result = [];
|
|
17542
17543
|
|
|
@@ -17568,7 +17569,6 @@ function requireWrapQuery$2 () {
|
|
|
17568
17569
|
return Buffer.from(str, 'utf8').toString('hex');
|
|
17569
17570
|
}
|
|
17570
17571
|
|
|
17571
|
-
|
|
17572
17572
|
wrapQuery_1$2 = wrapQuery;
|
|
17573
17573
|
return wrapQuery_1$2;
|
|
17574
17574
|
}
|
package/docs/changelog.md
CHANGED
package/package.json
CHANGED
package/src/mssql/wrapQuery.js
CHANGED
|
@@ -8,6 +8,7 @@ function wrapQuery(_context, connection) {
|
|
|
8
8
|
function runQuery(query, onCompleted) {
|
|
9
9
|
var params = query.parameters;
|
|
10
10
|
var sql = query.sql();
|
|
11
|
+
log.emitQuery({ sql, parameters: params });
|
|
11
12
|
|
|
12
13
|
const replacements = [];
|
|
13
14
|
const parametersToRemove = [];
|
|
@@ -15,7 +16,6 @@ function wrapQuery(_context, connection) {
|
|
|
15
16
|
|
|
16
17
|
if (engine === 'sap') {
|
|
17
18
|
const sap = connection.msnodesqlv8;
|
|
18
|
-
// Helper function to check for non-ASCII UTF-8 characters
|
|
19
19
|
|
|
20
20
|
// Check if this is a stored procedure call
|
|
21
21
|
const isStoredProcCall = /EXECUTE\s+/i.test(sql) || /EXEC\s+/i.test(sql);
|
|
@@ -26,17 +26,19 @@ function wrapQuery(_context, connection) {
|
|
|
26
26
|
const parameter = params[i];
|
|
27
27
|
|
|
28
28
|
if (typeof parameter === 'string') {
|
|
29
|
-
|
|
29
|
+
const paramLength = parameter.length;
|
|
30
|
+
const byteLength = Buffer.from(parameter, 'utf8').length;
|
|
30
31
|
|
|
32
|
+
if (hasNonAsciiCharacters(parameter)) {
|
|
31
33
|
const hexValue = stringToHex(parameter);
|
|
32
34
|
|
|
33
35
|
if (isStoredProcCall) {
|
|
34
|
-
// For stored procedures, create a variable
|
|
36
|
+
// For stored procedures, create a variable with exact lengths
|
|
35
37
|
const varName = `@hex_param_${i}`;
|
|
36
|
-
const convertClause = `CONVERT(VARCHAR(
|
|
38
|
+
const convertClause = `CONVERT(VARCHAR(${paramLength}), CONVERT(VARBINARY(${byteLength}), 0x${hexValue}))`;
|
|
37
39
|
|
|
38
40
|
hexVariables.push({
|
|
39
|
-
declaration: `DECLARE ${varName} VARCHAR(
|
|
41
|
+
declaration: `DECLARE ${varName} VARCHAR(${paramLength})`,
|
|
40
42
|
assignment: `SET ${varName} = ${convertClause}`
|
|
41
43
|
});
|
|
42
44
|
|
|
@@ -45,17 +47,18 @@ function wrapQuery(_context, connection) {
|
|
|
45
47
|
replacement: varName
|
|
46
48
|
});
|
|
47
49
|
} else {
|
|
48
|
-
// For regular queries, use inline conversion
|
|
49
|
-
const convertClause = `CONVERT(VARCHAR(
|
|
50
|
+
// For regular queries, use inline conversion with exact lengths
|
|
51
|
+
const convertClause = `CONVERT(VARCHAR(${paramLength}), CONVERT(VARBINARY(${byteLength}), 0x${hexValue}))`;
|
|
50
52
|
replacements.push({
|
|
51
53
|
index: i,
|
|
52
54
|
replacement: convertClause
|
|
53
55
|
});
|
|
54
56
|
}
|
|
55
57
|
parametersToRemove.push(i);
|
|
58
|
+
} else {
|
|
59
|
+
// For ASCII strings, use VarChar with exact byte length
|
|
60
|
+
params[i] = sap.VarChar(parameter, byteLength);
|
|
56
61
|
}
|
|
57
|
-
else
|
|
58
|
-
params[i] = sap.VarChar(parameter);
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
|
|
@@ -99,8 +102,6 @@ function wrapQuery(_context, connection) {
|
|
|
99
102
|
});
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
log.emitQuery({ sql, parameters: params });
|
|
103
|
-
|
|
104
105
|
runOriginalQuery.call(connection, sql, params, onInnerCompleted);
|
|
105
106
|
let result = [];
|
|
106
107
|
|
|
@@ -132,5 +133,4 @@ function stringToHex(str) {
|
|
|
132
133
|
return Buffer.from(str, 'utf8').toString('hex');
|
|
133
134
|
}
|
|
134
135
|
|
|
135
|
-
|
|
136
136
|
module.exports = wrapQuery;
|