@mikro-orm/core 7.2.6-dev.40 → 7.2.6-dev.41

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.
@@ -1935,9 +1935,9 @@ export class MetadataDiscovery {
1935
1935
  // guard preserves the legacy convention where JSON defaults are passed pre-stringified.
1936
1936
  // Array defaults are converted unconditionally (e.g. `default: []` on a JSON-backed embedded array).
1937
1937
  if (prop.customType && (Array.isArray(prop.default) || prop.customType.compareAsType() !== 'any')) {
1938
- val = prop.customType.convertToDatabaseValue(prop.default, this.#platform);
1938
+ val = prop.customType.convertToDatabaseValue(prop.default, this.#platform, { mode: 'discovery' });
1939
1939
  }
1940
- prop.defaultRaw = typeof val === 'string' ? `'${val.replaceAll("'", "''")}'` : '' + val;
1940
+ prop.defaultRaw = typeof val === 'string' ? this.#platform.quoteDefaultValue(val) : '' + val;
1941
1941
  }
1942
1942
  inferTypeFromDefault(prop) {
1943
1943
  if ((prop.defaultRaw == null && prop.default == null) || prop.type !== 'any') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.2.6-dev.40",
3
+ "version": "7.2.6-dev.41",
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",
@@ -274,6 +274,8 @@ export declare abstract class Platform {
274
274
  }, quote?: string): string;
275
275
  /** Quotes a literal value for safe embedding in SQL. */
276
276
  quoteValue(value: any): string;
277
+ /** Quotes a string default value for DDL; dialects that escape with backslashes override this. */
278
+ quoteDefaultValue(value: string): string;
277
279
  escape(value: any): string;
278
280
  /** Replaces `?` placeholders in SQL with quoted parameter values. */
279
281
  formatQuery(sql: string, params: readonly any[]): string;
@@ -573,6 +573,10 @@ export class Platform {
573
573
  quoteValue(value) {
574
574
  return value;
575
575
  }
576
+ /** Quotes a string default value for DDL; dialects that escape with backslashes override this. */
577
+ quoteDefaultValue(value) {
578
+ return `'${value.replaceAll("'", "''")}'`;
579
+ }
576
580
  /* v8 ignore next */
577
581
  escape(value) {
578
582
  return 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.6-dev.40';
156
+ static #ORM_VERSION = '7.2.6-dev.41';
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}`;