@mikro-orm/core 7.0.6-dev.5 → 7.0.6-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.
@@ -1490,7 +1490,7 @@ export class MetadataDiscovery {
1490
1490
  this.initFieldName(prop);
1491
1491
  let expression = null;
1492
1492
  if (prop.enum) {
1493
- expression = `${this.#platform.quoteIdentifier(prop.fieldNames[0])} in ('${prop.items.join("', '")}')`;
1493
+ expression = this.#platform.getEnumCheckConstraintExpression(prop.fieldNames[0], prop.items);
1494
1494
  }
1495
1495
  else if (prop.array) {
1496
1496
  expression = this.#platform.getEnumArrayCheckConstraintExpression(prop.fieldNames[0], prop.items);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.0.6-dev.5",
3
+ "version": "7.0.6-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",
@@ -37,6 +37,8 @@ export declare abstract class Platform {
37
37
  supportsNativeEnums(): boolean;
38
38
  /** for postgres text enums (default) */
39
39
  usesEnumCheckConstraints(): boolean;
40
+ /** Returns the check constraint expression for an enum column. */
41
+ getEnumCheckConstraintExpression(column: string, items: string[]): string;
40
42
  /** Returns the check constraint expression for an enum array column, or null if unsupported. */
41
43
  getEnumArrayCheckConstraintExpression(column: string, items: string[]): string | null;
42
44
  /** Whether this platform supports materialized views. */
@@ -50,6 +50,10 @@ export class Platform {
50
50
  usesEnumCheckConstraints() {
51
51
  return false;
52
52
  }
53
+ /** Returns the check constraint expression for an enum column. */
54
+ getEnumCheckConstraintExpression(column, items) {
55
+ return `${this.quoteIdentifier(column)} in (${items.map(v => this.quoteValue(v)).join(', ')})`;
56
+ }
53
57
  /** Returns the check constraint expression for an enum array column, or null if unsupported. */
54
58
  getEnumArrayCheckConstraintExpression(column, items) {
55
59
  return null;
package/typings.js CHANGED
@@ -184,7 +184,9 @@ export class EntityMetadata {
184
184
  this.checks.push({
185
185
  name,
186
186
  property: prop.name,
187
- expression: `${config.getPlatform().quoteIdentifier(prop.fieldNames[0])} in ('${prop.items.join("', '")}')`,
187
+ expression: config
188
+ .getPlatform()
189
+ .getEnumCheckConstraintExpression(prop.fieldNames[0], prop.items),
188
190
  });
189
191
  }
190
192
  }
package/utils/Utils.js CHANGED
@@ -129,7 +129,7 @@ export function parseJsonSafe(value) {
129
129
  /** Collection of general-purpose utility methods used throughout the ORM. */
130
130
  export class Utils {
131
131
  static PK_SEPARATOR = '~~~';
132
- static #ORM_VERSION = '7.0.6-dev.5';
132
+ static #ORM_VERSION = '7.0.6-dev.7';
133
133
  /**
134
134
  * Checks if the argument is instance of `Object`. Returns false for arrays.
135
135
  */