@mikro-orm/core 7.0.6-dev.4 → 7.0.6-dev.6
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/metadata/MetadataDiscovery.js +1 -1
- package/package.json +1 -1
- package/platforms/Platform.d.ts +2 -0
- package/platforms/Platform.js +4 -0
- package/typings.js +3 -1
- package/utils/Utils.js +1 -1
|
@@ -1490,7 +1490,7 @@ export class MetadataDiscovery {
|
|
|
1490
1490
|
this.initFieldName(prop);
|
|
1491
1491
|
let expression = null;
|
|
1492
1492
|
if (prop.enum) {
|
|
1493
|
-
expression =
|
|
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.
|
|
3
|
+
"version": "7.0.6-dev.6",
|
|
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",
|
package/platforms/Platform.d.ts
CHANGED
|
@@ -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. */
|
package/platforms/Platform.js
CHANGED
|
@@ -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:
|
|
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.
|
|
132
|
+
static #ORM_VERSION = '7.0.6-dev.6';
|
|
133
133
|
/**
|
|
134
134
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
135
135
|
*/
|