@mikro-orm/knex 6.3.5-dev.17 → 6.3.5-dev.18

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.
@@ -16,6 +16,11 @@ export declare class MySqlPlatform extends AbstractSqlPlatform {
16
16
  convertJsonToDatabaseValue(value: unknown, context?: TransformContext): unknown;
17
17
  getJsonIndexDefinition(index: IndexDef): string[];
18
18
  getBooleanTypeDeclarationSQL(): string;
19
+ normalizeColumnType(type: string, options?: {
20
+ length?: number;
21
+ precision?: number;
22
+ scale?: number;
23
+ }): string;
19
24
  getDefaultMappedType(type: string): Type<unknown>;
20
25
  supportsUnsigned(): boolean;
21
26
  /**
@@ -36,6 +36,13 @@ class MySqlPlatform extends AbstractSqlPlatform_1.AbstractSqlPlatform {
36
36
  getBooleanTypeDeclarationSQL() {
37
37
  return 'tinyint(1)';
38
38
  }
39
+ normalizeColumnType(type, options = {}) {
40
+ const simpleType = this.extractSimpleType(type);
41
+ if (['decimal', 'numeric'].includes(simpleType)) {
42
+ return this.getDecimalTypeDeclarationSQL(options);
43
+ }
44
+ return type;
45
+ }
39
46
  getDefaultMappedType(type) {
40
47
  if (type === 'tinyint(1)') {
41
48
  return super.getDefaultMappedType('boolean');
@@ -36,6 +36,11 @@ export declare abstract class BaseSqlitePlatform extends AbstractSqlPlatform {
36
36
  getVarcharTypeDeclarationSQL(column: {
37
37
  length?: number;
38
38
  }): string;
39
+ normalizeColumnType(type: string, options?: {
40
+ length?: number;
41
+ precision?: number;
42
+ scale?: number;
43
+ }): string;
39
44
  convertsJsonAutomatically(): boolean;
40
45
  /**
41
46
  * This is used to narrow the value of Date properties as they will be stored as timestamps in sqlite.
@@ -44,6 +44,13 @@ class BaseSqlitePlatform extends AbstractSqlPlatform_1.AbstractSqlPlatform {
44
44
  getVarcharTypeDeclarationSQL(column) {
45
45
  return 'text';
46
46
  }
47
+ normalizeColumnType(type, options = {}) {
48
+ const simpleType = this.extractSimpleType(type);
49
+ if (['varchar', 'text'].includes(simpleType)) {
50
+ return this.getVarcharTypeDeclarationSQL(options);
51
+ }
52
+ return simpleType;
53
+ }
47
54
  convertsJsonAutomatically() {
48
55
  return false;
49
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.3.5-dev.17",
3
+ "version": "6.3.5-dev.18",
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,7 +66,7 @@
66
66
  "@mikro-orm/core": "^6.3.4"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.3.5-dev.17",
69
+ "@mikro-orm/core": "6.3.5-dev.18",
70
70
  "better-sqlite3": "*",
71
71
  "libsql": "*",
72
72
  "mariadb": "*"
@@ -385,9 +385,9 @@ class SchemaComparator {
385
385
  const changedProperties = new Set();
386
386
  const fromProp = this.mapColumnToProperty({ ...fromColumn, autoincrement: false });
387
387
  const toProp = this.mapColumnToProperty({ ...toColumn, autoincrement: false });
388
- const fromColumnType = fromColumn.mappedType.getColumnType(fromProp, this.platform).toLowerCase();
388
+ const fromColumnType = this.platform.normalizeColumnType(fromColumn.mappedType.getColumnType(fromProp, this.platform).toLowerCase(), fromProp);
389
389
  const fromNativeEnum = fromTable.nativeEnums[fromColumnType] ?? Object.values(fromTable.nativeEnums).find(e => e.name === fromColumnType && e.schema !== '*');
390
- const toColumnType = toColumn.mappedType.getColumnType(toProp, this.platform).toLowerCase();
390
+ const toColumnType = this.platform.normalizeColumnType(toColumn.mappedType.getColumnType(toProp, this.platform).toLowerCase(), toProp);
391
391
  const log = (msg, params) => {
392
392
  if (tableName) {
393
393
  const copy = core_1.Utils.copy(params);