@mikro-orm/knex 6.2.10-dev.0 → 6.2.10-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.2.10-dev.0",
3
+ "version": "6.2.10-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.2.9"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.2.10-dev.0",
69
+ "@mikro-orm/core": "6.2.10-dev.2",
70
70
  "better-sqlite3": "*",
71
71
  "libsql": "*",
72
72
  "mariadb": "*"
@@ -1,4 +1,4 @@
1
- import { type Configuration, type Dictionary, type EntityMetadata, type EntityProperty, type NamingStrategy } from '@mikro-orm/core';
1
+ import { type Configuration, type DeferMode, type Dictionary, type EntityMetadata, type EntityProperty, type NamingStrategy } from '@mikro-orm/core';
2
2
  import type { SchemaHelper } from './SchemaHelper';
3
3
  import type { CheckDef, Column, ForeignKey, IndexDef } from '../typings';
4
4
  import type { AbstractSqlPlatform } from '../AbstractSqlPlatform';
@@ -58,6 +58,7 @@ export declare class DatabaseTable {
58
58
  name?: string;
59
59
  type?: string;
60
60
  expression?: string;
61
+ deferMode?: DeferMode;
61
62
  options?: Dictionary;
62
63
  }, type: 'index' | 'unique' | 'primary'): void;
63
64
  addCheck(check: CheckDef): void;
@@ -482,7 +482,7 @@ class DatabaseTable {
482
482
  getForeignKeyDeclaration(fk, namingStrategy, schemaHelper, fkIndex, nullable, propNameBase) {
483
483
  const prop = this.getPropertyName(namingStrategy, propNameBase, fk);
484
484
  const kind = (fkIndex?.unique && !fkIndex.primary) ? this.getReferenceKind(fk, fkIndex) : this.getReferenceKind(fk);
485
- const type = this.getPropertyTypeForForeignKey(namingStrategy, fk);
485
+ const runtimeType = this.getPropertyTypeForForeignKey(namingStrategy, fk);
486
486
  const fkOptions = {};
487
487
  fkOptions.fieldNames = fk.columnNames;
488
488
  fkOptions.referencedTableName = fk.referencedTableName;
@@ -510,7 +510,8 @@ class DatabaseTable {
510
510
  }
511
511
  return {
512
512
  name: prop,
513
- type,
513
+ type: runtimeType,
514
+ runtimeType,
514
515
  kind,
515
516
  ...columnOptions,
516
517
  nullable,
@@ -526,9 +527,9 @@ class DatabaseTable {
526
527
  const index = compositeFkIndexes[prop] || this.indexes.find(idx => idx.columnNames[0] === column.name && !idx.composite && !idx.unique && !idx.primary);
527
528
  const unique = compositeFkUniques[prop] || this.indexes.find(idx => idx.columnNames[0] === column.name && !idx.composite && idx.unique && !idx.primary);
528
529
  const kind = this.getReferenceKind(fk, unique);
529
- const type = this.getPropertyTypeForColumn(namingStrategy, column, fk);
530
- const defaultRaw = this.getPropertyDefaultValue(schemaHelper, column, type, true);
531
- const defaultParsed = this.getPropertyDefaultValue(schemaHelper, column, type);
530
+ const runtimeType = this.getPropertyTypeForColumn(namingStrategy, column, fk);
531
+ const defaultRaw = this.getPropertyDefaultValue(schemaHelper, column, runtimeType, true);
532
+ const defaultParsed = this.getPropertyDefaultValue(schemaHelper, column, runtimeType);
532
533
  const defaultTs = defaultRaw !== defaultParsed ? defaultParsed : undefined;
533
534
  const fkOptions = {};
534
535
  if (fk) {
@@ -541,7 +542,8 @@ class DatabaseTable {
541
542
  }
542
543
  return {
543
544
  name: prop,
544
- type,
545
+ type: fk ? runtimeType : (core_1.Utils.entries(core_1.t).find(([k, v]) => Object.getPrototypeOf(column.mappedType) === v.prototype)?.[0] ?? runtimeType),
546
+ runtimeType,
545
547
  kind,
546
548
  generated: column.generated,
547
549
  optional: defaultRaw !== 'null' || defaultTs != null || typeof column.generated !== 'undefined',
@@ -657,6 +659,7 @@ class DatabaseTable {
657
659
  type: index.type,
658
660
  expression: index.expression,
659
661
  options: index.options,
662
+ deferMode: index.deferMode,
660
663
  });
661
664
  }
662
665
  addCheck(check) {