@mikro-orm/core 7.2.11-dev.5 → 7.2.11-dev.7
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/package.json +1 -1
- package/platforms/Platform.js +1 -1
- package/utils/Utils.js +40 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.2.11-dev.
|
|
3
|
+
"version": "7.2.11-dev.7",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
package/platforms/Platform.js
CHANGED
|
@@ -574,7 +574,7 @@ export class Platform {
|
|
|
574
574
|
return this.formatQuery(raw.sql, raw.params);
|
|
575
575
|
}
|
|
576
576
|
const escaped = id.toString().replaceAll(quote, quote + quote);
|
|
577
|
-
return `${quote}${escaped.
|
|
577
|
+
return `${quote}${escaped.replaceAll('.', `${quote}.${quote}`)}${quote}`;
|
|
578
578
|
}
|
|
579
579
|
/** Quotes a literal value for safe embedding in SQL. */
|
|
580
580
|
quoteValue(value) {
|
package/utils/Utils.js
CHANGED
|
@@ -153,7 +153,7 @@ export function parseJsonSafe(value) {
|
|
|
153
153
|
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
154
154
|
export class Utils {
|
|
155
155
|
static PK_SEPARATOR = '~~~';
|
|
156
|
-
static #ORM_VERSION = '7.2.11-dev.
|
|
156
|
+
static #ORM_VERSION = '7.2.11-dev.7';
|
|
157
157
|
/** Default session variable name backing an RLS filter argument (`current_setting('mikro.<filter>.<arg>')`). */
|
|
158
158
|
static getRlsSettingName(filterName, argName) {
|
|
159
159
|
return `mikro.${filterName}.${argName}`;
|
|
@@ -335,23 +335,55 @@ export class Utils {
|
|
|
335
335
|
}
|
|
336
336
|
let depth = 0;
|
|
337
337
|
let end = start;
|
|
338
|
+
let paramStart = start + 1;
|
|
339
|
+
const params = [];
|
|
340
|
+
let quote;
|
|
338
341
|
for (; end < source.length; end++) {
|
|
339
|
-
if (
|
|
342
|
+
if (quote) {
|
|
343
|
+
if (source[end] === '\\') {
|
|
344
|
+
end++;
|
|
345
|
+
}
|
|
346
|
+
else if (source[end] === quote) {
|
|
347
|
+
quote = undefined;
|
|
348
|
+
}
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
const commentEnd = source.startsWith('/*', end) ? '*/' : source.startsWith('//', end) ? '\n' : undefined;
|
|
352
|
+
if (commentEnd) {
|
|
353
|
+
const close = source.indexOf(commentEnd, end + 2);
|
|
354
|
+
end = close === -1 ? source.length : close + commentEnd.length - 1;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
// a slash that does not follow an operand starts a regex literal
|
|
358
|
+
if (source[end] === '/' && !/[\w$)\]]\s*$/.test(source.slice(start, end))) {
|
|
359
|
+
const regex = /\/(?:\\.|\[(?:\\.|[^\]\\])*\]|[^/\\[\n])+\//y;
|
|
360
|
+
regex.lastIndex = end;
|
|
361
|
+
end += (regex.exec(source)?.[0].length ?? 1) - 1;
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (`'"\``.includes(source[end])) {
|
|
365
|
+
quote = source[end];
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
if ('([{'.includes(source[end])) {
|
|
340
369
|
depth++;
|
|
341
370
|
}
|
|
342
|
-
if (source[end]
|
|
371
|
+
if (')]}'.includes(source[end])) {
|
|
343
372
|
depth--;
|
|
344
373
|
}
|
|
345
374
|
if (depth === 0) {
|
|
346
375
|
break;
|
|
347
376
|
}
|
|
377
|
+
if (depth === 1 && source[end] === ',') {
|
|
378
|
+
params.push(source.slice(paramStart, end));
|
|
379
|
+
paramStart = end + 1;
|
|
380
|
+
}
|
|
348
381
|
}
|
|
349
|
-
|
|
350
|
-
return
|
|
351
|
-
.
|
|
352
|
-
.map(s => s.trim().replace(/=.*$/, '').trim())
|
|
382
|
+
params.push(source.slice(paramStart, end));
|
|
383
|
+
return params
|
|
384
|
+
.map(s => s.replace(/\/\*.*?\*\/|\/\/[^\n]*/gs, '').trim())
|
|
353
385
|
.filter(Boolean)
|
|
354
|
-
.map(raw => (
|
|
386
|
+
.map(raw => (/^[{[]/.test(raw) ? '' : raw.replace(/=.*$/s, '').trim()));
|
|
355
387
|
}
|
|
356
388
|
/**
|
|
357
389
|
* Checks whether the argument looks like primary key (string, number or ObjectId).
|