@mikro-orm/knex 6.6.9-dev.1 → 6.6.9-dev.2

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.6.9-dev.1",
3
+ "version": "6.6.9-dev.2",
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.6.8"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.6.9-dev.1",
69
+ "@mikro-orm/core": "6.6.9-dev.2",
70
70
  "better-sqlite3": "*",
71
71
  "libsql": "*",
72
72
  "mariadb": "*"
@@ -76,14 +76,15 @@ class DatabaseTable {
76
76
  prop.length ??= mappedType.getDefaultLength(this.platform);
77
77
  }
78
78
  }
79
- const primary = !meta.compositePK && !!prop.primary && prop.kind === core_1.ReferenceKind.SCALAR && this.platform.isNumericColumn(mappedType);
79
+ const primary = !!prop.primary;
80
+ const autoincrement = !meta.compositePK && primary && prop.kind === core_1.ReferenceKind.SCALAR && this.platform.isNumericColumn(mappedType);
80
81
  this.columns[field] = {
81
82
  name: prop.fieldNames[idx],
82
83
  type: prop.columnTypes[idx],
83
84
  generated: prop.generated,
84
85
  mappedType,
85
86
  unsigned: prop.unsigned && this.platform.isNumericColumn(mappedType),
86
- autoincrement: prop.autoincrement ?? primary,
87
+ autoincrement: prop.autoincrement ?? autoincrement,
87
88
  primary,
88
89
  nullable: this.columns[field]?.nullable ?? !!prop.nullable,
89
90
  nativeEnumName: prop.nativeEnumName,
@@ -782,9 +783,36 @@ class DatabaseTable {
782
783
  toJSON() {
783
784
  const { platform, columns, ...rest } = this;
784
785
  const columnsMapped = core_1.Utils.keys(columns).reduce((o, col) => {
785
- const { mappedType, ...restCol } = columns[col];
786
- o[col] = restCol;
787
- o[col].mappedType = core_1.Utils.keys(core_1.t).find(k => core_1.t[k] === mappedType.constructor);
786
+ const c = columns[col];
787
+ const normalized = {
788
+ name: c.name,
789
+ type: c.type,
790
+ unsigned: !!c.unsigned,
791
+ autoincrement: !!c.autoincrement,
792
+ primary: !!c.primary,
793
+ nullable: !!c.nullable,
794
+ unique: !!c.unique,
795
+ length: c.length ?? null,
796
+ precision: c.precision ?? null,
797
+ scale: c.scale ?? null,
798
+ default: c.default ?? null,
799
+ comment: c.comment ?? null,
800
+ enumItems: c.enumItems ?? [],
801
+ mappedType: core_1.Utils.keys(core_1.t).find(k => core_1.t[k] === c.mappedType.constructor),
802
+ };
803
+ if (c.generated) {
804
+ normalized.generated = c.generated;
805
+ }
806
+ if (c.nativeEnumName) {
807
+ normalized.nativeEnumName = c.nativeEnumName;
808
+ }
809
+ if (c.extra) {
810
+ normalized.extra = c.extra;
811
+ }
812
+ if (c.ignoreSchemaChanges) {
813
+ normalized.ignoreSchemaChanges = c.ignoreSchemaChanges;
814
+ }
815
+ o[col] = normalized;
788
816
  return o;
789
817
  }, {});
790
818
  return { columns: columnsMapped, ...rest };
@@ -414,7 +414,7 @@ class SchemaComparator {
414
414
  changedProperties.add('type');
415
415
  }
416
416
  }
417
- if (fromColumn.nullable !== toColumn.nullable && !fromColumn.generated && !toColumn.generated) {
417
+ if (!!fromColumn.nullable !== !!toColumn.nullable && !fromColumn.generated && !toColumn.generated) {
418
418
  log(`'nullable' changed for column ${tableName}.${fromColumn.name}`, { fromColumn, toColumn });
419
419
  changedProperties.add('nullable');
420
420
  }
@@ -426,7 +426,7 @@ class SchemaComparator {
426
426
  log(`'autoincrement' changed for column ${tableName}.${fromColumn.name}`, { fromColumn, toColumn });
427
427
  changedProperties.add('autoincrement');
428
428
  }
429
- if (fromColumn.unsigned !== toColumn.unsigned && this.platform.supportsUnsigned()) {
429
+ if (!!fromColumn.unsigned !== !!toColumn.unsigned && this.platform.supportsUnsigned()) {
430
430
  log(`'unsigned' changed for column ${tableName}.${fromColumn.name}`, { fromColumn, toColumn });
431
431
  changedProperties.add('unsigned');
432
432
  }