@mikro-orm/knex 6.0.0-dev.228 → 6.0.0-dev.229
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.0.0-dev.
|
|
3
|
+
"version": "6.0.0-dev.229",
|
|
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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -66,6 +66,6 @@
|
|
|
66
66
|
"@mikro-orm/core": "^5.9.2"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.0.0-dev.
|
|
69
|
+
"@mikro-orm/core": "6.0.0-dev.229"
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Dictionary } from '@mikro-orm/core';
|
|
1
2
|
import type { Column, ForeignKey, IndexDef, SchemaDifference, TableDifference } from '../typings';
|
|
2
3
|
import type { DatabaseSchema } from './DatabaseSchema';
|
|
3
4
|
import type { DatabaseTable } from './DatabaseTable';
|
|
@@ -51,6 +52,7 @@ export declare class SchemaComparator {
|
|
|
51
52
|
*/
|
|
52
53
|
isIndexFulfilledBy(index1: IndexDef, index2: IndexDef): boolean;
|
|
53
54
|
diffExpression(expr1: string, expr2: string): boolean;
|
|
55
|
+
parseJsonDefault(defaultValue?: string | null): Dictionary | string | null;
|
|
54
56
|
hasSameDefaultValue(from: Column, to: Column): boolean;
|
|
55
57
|
private mapColumnToProperty;
|
|
56
58
|
private log;
|
|
@@ -449,6 +449,15 @@ class SchemaComparator {
|
|
|
449
449
|
const simplify = (str) => str?.replace(/_\w+\\'(.*?)\\'/g, '$1').replace(/['"`()]|::\w+| +/g, '').toLowerCase();
|
|
450
450
|
return simplify(expr1) !== simplify(expr2);
|
|
451
451
|
}
|
|
452
|
+
parseJsonDefault(defaultValue) {
|
|
453
|
+
if (!defaultValue) {
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
const val = defaultValue
|
|
457
|
+
.replace(/^(_\w+\\)?'(.*?)\\?'$/, '$2')
|
|
458
|
+
.replace(/^\(?'(.*?)'\)?$/, '$1');
|
|
459
|
+
return (0, core_1.parseJsonSafe)(val);
|
|
460
|
+
}
|
|
452
461
|
hasSameDefaultValue(from, to) {
|
|
453
462
|
if (from.default == null || from.default.toString().toLowerCase() === 'null' || from.default.toString().startsWith('nextval(')) {
|
|
454
463
|
return to.default == null || to.default.toLowerCase() === 'null';
|
|
@@ -459,8 +468,8 @@ class SchemaComparator {
|
|
|
459
468
|
return defaultValueFrom === defaultValueTo;
|
|
460
469
|
}
|
|
461
470
|
if (to.mappedType instanceof core_1.JsonType) {
|
|
462
|
-
const defaultValueFrom =
|
|
463
|
-
const defaultValueTo =
|
|
471
|
+
const defaultValueFrom = this.parseJsonDefault(from.default);
|
|
472
|
+
const defaultValueTo = this.parseJsonDefault(to.default);
|
|
464
473
|
return core_1.Utils.equals(defaultValueFrom, defaultValueTo);
|
|
465
474
|
}
|
|
466
475
|
if (to.mappedType instanceof core_1.DateTimeType && from.default && to.default) {
|