orange-orm 4.7.5-beta.1 → 4.7.5

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 CHANGED
@@ -17451,7 +17451,6 @@ function requireWrapQuery$2 () {
17451
17451
 
17452
17452
  if (engine === 'sap') {
17453
17453
  const sap = connection.msnodesqlv8;
17454
- // Helper function to check for non-ASCII UTF-8 characters
17455
17454
 
17456
17455
  // Check if this is a stored procedure call
17457
17456
  const isStoredProcCall = /EXECUTE\s+/i.test(sql) || /EXEC\s+/i.test(sql);
@@ -17462,17 +17461,19 @@ function requireWrapQuery$2 () {
17462
17461
  const parameter = params[i];
17463
17462
 
17464
17463
  if (typeof parameter === 'string') {
17465
- if (hasNonAsciiCharacters(parameter)) {
17464
+ const paramLength = parameter.length;
17465
+ const byteLength = Buffer.from(parameter, 'utf8').length;
17466
17466
 
17467
+ if (hasNonAsciiCharacters(parameter)) {
17467
17468
  const hexValue = stringToHex(parameter);
17468
17469
 
17469
17470
  if (isStoredProcCall) {
17470
- // For stored procedures, create a variable
17471
+ // For stored procedures, create a variable with exact lengths
17471
17472
  const varName = `@hex_param_${i}`;
17472
- const convertClause = `CONVERT(VARCHAR(255), CONVERT(VARBINARY(127), 0x${hexValue}))`;
17473
+ const convertClause = `CONVERT(VARCHAR(${paramLength}), CONVERT(VARBINARY(${byteLength}), 0x${hexValue}))`;
17473
17474
 
17474
17475
  hexVariables.push({
17475
- declaration: `DECLARE ${varName} VARCHAR(255)`,
17476
+ declaration: `DECLARE ${varName} VARCHAR(${paramLength})`,
17476
17477
  assignment: `SET ${varName} = ${convertClause}`
17477
17478
  });
17478
17479
 
@@ -17481,17 +17482,18 @@ function requireWrapQuery$2 () {
17481
17482
  replacement: varName
17482
17483
  });
17483
17484
  } else {
17484
- // For regular queries, use inline conversion
17485
- const convertClause = `CONVERT(VARCHAR(255), CONVERT(VARBINARY(127), 0x${hexValue}))`;
17485
+ // For regular queries, use inline conversion with exact lengths
17486
+ const convertClause = `CONVERT(VARCHAR(${paramLength}), CONVERT(VARBINARY(${byteLength}), 0x${hexValue}))`;
17486
17487
  replacements.push({
17487
17488
  index: i,
17488
17489
  replacement: convertClause
17489
17490
  });
17490
17491
  }
17491
17492
  parametersToRemove.push(i);
17493
+ } else {
17494
+ // For ASCII strings, use VarChar with exact byte length
17495
+ params[i] = sap.VarChar(parameter, byteLength);
17492
17496
  }
17493
- else
17494
- params[i] = sap.VarChar(parameter);
17495
17497
  }
17496
17498
  }
17497
17499
 
@@ -17568,7 +17570,6 @@ function requireWrapQuery$2 () {
17568
17570
  return Buffer.from(str, 'utf8').toString('hex');
17569
17571
  }
17570
17572
 
17571
-
17572
17573
  wrapQuery_1$2 = wrapQuery;
17573
17574
  return wrapQuery_1$2;
17574
17575
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orange-orm",
3
- "version": "4.7.5-beta.1",
3
+ "version": "4.7.5",
4
4
  "main": "./src/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "browser": "./dist/index.browser.mjs",
@@ -15,7 +15,6 @@ function wrapQuery(_context, connection) {
15
15
 
16
16
  if (engine === 'sap') {
17
17
  const sap = connection.msnodesqlv8;
18
- // Helper function to check for non-ASCII UTF-8 characters
19
18
 
20
19
  // Check if this is a stored procedure call
21
20
  const isStoredProcCall = /EXECUTE\s+/i.test(sql) || /EXEC\s+/i.test(sql);
@@ -26,17 +25,19 @@ function wrapQuery(_context, connection) {
26
25
  const parameter = params[i];
27
26
 
28
27
  if (typeof parameter === 'string') {
29
- if (hasNonAsciiCharacters(parameter)) {
28
+ const paramLength = parameter.length;
29
+ const byteLength = Buffer.from(parameter, 'utf8').length;
30
30
 
31
+ if (hasNonAsciiCharacters(parameter)) {
31
32
  const hexValue = stringToHex(parameter);
32
33
 
33
34
  if (isStoredProcCall) {
34
- // For stored procedures, create a variable
35
+ // For stored procedures, create a variable with exact lengths
35
36
  const varName = `@hex_param_${i}`;
36
- const convertClause = `CONVERT(VARCHAR(255), CONVERT(VARBINARY(127), 0x${hexValue}))`;
37
+ const convertClause = `CONVERT(VARCHAR(${paramLength}), CONVERT(VARBINARY(${byteLength}), 0x${hexValue}))`;
37
38
 
38
39
  hexVariables.push({
39
- declaration: `DECLARE ${varName} VARCHAR(255)`,
40
+ declaration: `DECLARE ${varName} VARCHAR(${paramLength})`,
40
41
  assignment: `SET ${varName} = ${convertClause}`
41
42
  });
42
43
 
@@ -45,17 +46,18 @@ function wrapQuery(_context, connection) {
45
46
  replacement: varName
46
47
  });
47
48
  } else {
48
- // For regular queries, use inline conversion
49
- const convertClause = `CONVERT(VARCHAR(255), CONVERT(VARBINARY(127), 0x${hexValue}))`;
49
+ // For regular queries, use inline conversion with exact lengths
50
+ const convertClause = `CONVERT(VARCHAR(${paramLength}), CONVERT(VARBINARY(${byteLength}), 0x${hexValue}))`;
50
51
  replacements.push({
51
52
  index: i,
52
53
  replacement: convertClause
53
54
  });
54
55
  }
55
56
  parametersToRemove.push(i);
57
+ } else {
58
+ // For ASCII strings, use VarChar with exact byte length
59
+ params[i] = sap.VarChar(parameter, byteLength);
56
60
  }
57
- else
58
- params[i] = sap.VarChar(parameter);
59
61
  }
60
62
  }
61
63
 
@@ -132,5 +134,4 @@ function stringToHex(str) {
132
134
  return Buffer.from(str, 'utf8').toString('hex');
133
135
  }
134
136
 
135
-
136
137
  module.exports = wrapQuery;