@mikro-orm/sql 7.1.0-dev.27 → 7.1.0-dev.28
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/AbstractSqlPlatform.d.ts
CHANGED
|
@@ -30,7 +30,8 @@ export declare abstract class AbstractSqlPlatform extends Platform {
|
|
|
30
30
|
getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean, value?: unknown): string | RawQueryFragment;
|
|
31
31
|
/**
|
|
32
32
|
* Quotes a key for use inside a JSON path expression (e.g. `$.key`).
|
|
33
|
-
* Simple alphanumeric keys are left unquoted; others are wrapped in double quotes
|
|
33
|
+
* Simple alphanumeric keys are left unquoted; others are wrapped in double quotes
|
|
34
|
+
* with embedded `\` and `"` escaped per the JSON path string syntax.
|
|
34
35
|
* @internal
|
|
35
36
|
*/
|
|
36
37
|
quoteJsonKey(key: string): string;
|
package/AbstractSqlPlatform.js
CHANGED
|
@@ -66,18 +66,23 @@ export class AbstractSqlPlatform extends Platform {
|
|
|
66
66
|
}
|
|
67
67
|
getSearchJsonPropertyKey(path, type, aliased, value) {
|
|
68
68
|
const [a, ...b] = path;
|
|
69
|
+
const jsonPath = this.quoteValue(`$.${b.map(this.quoteJsonKey).join('.')}`);
|
|
69
70
|
if (aliased) {
|
|
70
|
-
return raw(alias => `json_extract(${this.quoteIdentifier(`${alias}.${a}`)},
|
|
71
|
+
return raw(alias => `json_extract(${this.quoteIdentifier(`${alias}.${a}`)}, ${jsonPath})`);
|
|
71
72
|
}
|
|
72
|
-
return raw(`json_extract(${this.quoteIdentifier(a)},
|
|
73
|
+
return raw(`json_extract(${this.quoteIdentifier(a)}, ${jsonPath})`);
|
|
73
74
|
}
|
|
74
75
|
/**
|
|
75
76
|
* Quotes a key for use inside a JSON path expression (e.g. `$.key`).
|
|
76
|
-
* Simple alphanumeric keys are left unquoted; others are wrapped in double quotes
|
|
77
|
+
* Simple alphanumeric keys are left unquoted; others are wrapped in double quotes
|
|
78
|
+
* with embedded `\` and `"` escaped per the JSON path string syntax.
|
|
77
79
|
* @internal
|
|
78
80
|
*/
|
|
79
81
|
quoteJsonKey(key) {
|
|
80
|
-
|
|
82
|
+
if (/^[a-z]\w*$/i.test(key)) {
|
|
83
|
+
return key;
|
|
84
|
+
}
|
|
85
|
+
return `"${key.replaceAll('\\', '\\\\').replaceAll('"', '\\"')}"`;
|
|
81
86
|
}
|
|
82
87
|
getJsonIndexDefinition(index) {
|
|
83
88
|
return index.columnNames.map(column => {
|
|
@@ -246,9 +246,9 @@ export class BasePostgreSqlPlatform extends AbstractSqlPlatform {
|
|
|
246
246
|
lastOperator = '->';
|
|
247
247
|
}
|
|
248
248
|
if (path.length === 0) {
|
|
249
|
-
return cast(`${root}${lastOperator}
|
|
249
|
+
return cast(`${root}${lastOperator}${this.quoteValue(last)}`);
|
|
250
250
|
}
|
|
251
|
-
return cast(`${root}->${path.map(a => this.quoteValue(a)).join('->')}${lastOperator}
|
|
251
|
+
return cast(`${root}->${path.map(a => this.quoteValue(a)).join('->')}${lastOperator}${this.quoteValue(last)}`);
|
|
252
252
|
}
|
|
253
253
|
getJsonIndexDefinition(index) {
|
|
254
254
|
return index.columnNames.map(column => {
|
|
@@ -268,7 +268,8 @@ export class BasePostgreSqlPlatform extends AbstractSqlPlatform {
|
|
|
268
268
|
if (RawQueryFragment.isKnownFragment(id)) {
|
|
269
269
|
return super.quoteIdentifier(id);
|
|
270
270
|
}
|
|
271
|
-
|
|
271
|
+
const escaped = id.toString().replaceAll(quote, quote + quote);
|
|
272
|
+
return `${quote}${escaped.replace('.', `${quote}.${quote}`)}${quote}`;
|
|
272
273
|
}
|
|
273
274
|
pad(number, digits) {
|
|
274
275
|
return String(number).padStart(digits, '0');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.1.0-dev.
|
|
3
|
+
"version": "7.1.0-dev.28",
|
|
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",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"kysely": "0.28.
|
|
50
|
+
"kysely": "0.28.17"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@mikro-orm/core": "^7.0.
|
|
53
|
+
"@mikro-orm/core": "^7.0.14"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.1.0-dev.
|
|
56
|
+
"@mikro-orm/core": "7.1.0-dev.28"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|