@mikro-orm/sql 7.2.9-dev.11 → 7.2.9-dev.13

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,6 +62,7 @@ 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
+ normalizeExpression(expr: string): string;
65
66
  /** Decodes the backslash escapes of an introspected string literal. */
66
67
  unescapeDefault(val: string): string;
67
68
  }
@@ -295,12 +295,14 @@ export class MySqlSchemaHelper extends SchemaHelper {
295
295
  const ret = {};
296
296
  for (const check of allChecks) {
297
297
  const key = this.getTableKey(check);
298
+ // string literals come back escaped twice, decoded one level the same as the defaults in `wrap()`
299
+ const expression = check.expression.replace(/\\(.)/gs, '$1');
298
300
  ret[key] ??= [];
299
301
  ret[key].push({
300
302
  name: check.name,
301
303
  columnName: check.column_name,
302
- definition: `check ${check.expression}`,
303
- expression: check.expression.replace(/^\((.*)\)$/, '$1'),
304
+ definition: `check ${expression}`,
305
+ expression: expression.replace(/^\((.*)\)$/, '$1'),
304
306
  });
305
307
  }
306
308
  return ret;
@@ -610,6 +612,10 @@ export class MySqlSchemaHelper extends SchemaHelper {
610
612
  const stringType = type instanceof StringType || type instanceof TextType || type instanceof EnumType;
611
613
  return stringType ? this.platform.quoteDefaultValue(val) : val;
612
614
  }
615
+ normalizeExpression(expr) {
616
+ // `\'` and `''` are the same quote inside a literal
617
+ return expr.replace(/\\(.)/gs, (escape, char) => (char === "'" ? "''" : escape));
618
+ }
613
619
  /** Decodes the backslash escapes of an introspected string literal. */
614
620
  unescapeDefault(val) {
615
621
  const sqlEscapes = { 0: '\0', b: '\b', n: '\n', r: '\r', t: '\t', Z: '\x1a' };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.2.9-dev.11",
3
+ "version": "7.2.9-dev.13",
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.8"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.2.9-dev.11"
56
+ "@mikro-orm/core": "7.2.9-dev.13"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"