@mikro-orm/sql 7.2.6-dev.37 → 7.2.6-dev.39
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.
|
@@ -62,4 +62,8 @@ export declare class MySqlSchemaHelper extends SchemaHelper {
|
|
|
62
62
|
protected getChecksSQL(tables: Table[]): string;
|
|
63
63
|
normalizeDefaultValue(defaultValue: string, length: number): string | number;
|
|
64
64
|
protected wrap(val: string | null | undefined, type: Type<unknown>): string | null | undefined;
|
|
65
|
+
/** Decodes the backslash escapes of an introspected string literal. */
|
|
66
|
+
protected unescapeDefault(val: string): string;
|
|
67
|
+
/** Metadata doubles embedded quotes and leaves `"` alone, so undo those two escapes of `quoteValue` while keeping the backslash form of control characters. */
|
|
68
|
+
protected quoteDefault(val: string): string;
|
|
65
69
|
}
|
|
@@ -607,11 +607,18 @@ export class MySqlSchemaHelper extends SchemaHelper {
|
|
|
607
607
|
// text/blob literal defaults come back escaped twice with a charset introducer, e.g. `_utf8mb4\'it\\\'s\'` (JSON is parsed by the comparator)
|
|
608
608
|
const expression = type instanceof JsonType ? null : /^_\w+\\'(.*)\\'$/s.exec(val);
|
|
609
609
|
if (expression) {
|
|
610
|
-
|
|
611
|
-
const sqlEscapes = { 0: '\0', b: '\b', n: '\n', r: '\r', t: '\t', Z: '\x1a' };
|
|
612
|
-
return this.platform.quoteValue(unescape(unescape(expression[1]), sqlEscapes));
|
|
610
|
+
return this.quoteDefault(this.unescapeDefault(expression[1].replace(/\\(.)/gs, '$1')));
|
|
613
611
|
}
|
|
614
612
|
const stringType = type instanceof StringType || type instanceof TextType || type instanceof EnumType;
|
|
615
|
-
return stringType ? this.
|
|
613
|
+
return stringType ? this.quoteDefault(val) : val;
|
|
614
|
+
}
|
|
615
|
+
/** Decodes the backslash escapes of an introspected string literal. */
|
|
616
|
+
unescapeDefault(val) {
|
|
617
|
+
const sqlEscapes = { 0: '\0', b: '\b', n: '\n', r: '\r', t: '\t', Z: '\x1a' };
|
|
618
|
+
return val.replace(/\\(.)/gs, (_, char) => sqlEscapes[char] ?? char);
|
|
619
|
+
}
|
|
620
|
+
/** Metadata doubles embedded quotes and leaves `"` alone, so undo those two escapes of `quoteValue` while keeping the backslash form of control characters. */
|
|
621
|
+
quoteDefault(val) {
|
|
622
|
+
return this.platform.quoteValue(val).replaceAll("\\'", "''").replaceAll('\\"', '"');
|
|
616
623
|
}
|
|
617
624
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.2.6-dev.
|
|
3
|
+
"version": "7.2.6-dev.39",
|
|
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",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@mikro-orm/core": "^7.2.5"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.2.6-dev.
|
|
56
|
+
"@mikro-orm/core": "7.2.6-dev.39"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|
package/schema/DatabaseTable.js
CHANGED