@mikro-orm/knex 6.5.8-dev.10 → 6.5.8-dev.12

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.5.8-dev.10",
3
+ "version": "6.5.8-dev.12",
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.5.7"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.5.8-dev.10",
69
+ "@mikro-orm/core": "6.5.8-dev.12",
70
70
  "better-sqlite3": "*",
71
71
  "libsql": "*",
72
72
  "mariadb": "*"
@@ -109,33 +109,34 @@ class DatabaseTable {
109
109
  if (prop.referencedTableName.includes('.')) {
110
110
  schema = undefined;
111
111
  }
112
- this.foreignKeys[constraintName] = {
113
- constraintName,
114
- columnNames: prop.fieldNames,
115
- localTableName: this.getShortestName(),
116
- referencedColumnNames: prop.referencedColumnNames,
117
- referencedTableName: schema ? `${schema}.${prop.referencedTableName}` : prop.referencedTableName,
118
- createForeignKeyConstraint: prop.createForeignKeyConstraint,
119
- };
120
- const cascade = prop.cascade.includes(core_1.Cascade.REMOVE) || prop.cascade.includes(core_1.Cascade.ALL);
121
- if (prop.deleteRule || cascade || prop.nullable) {
122
- this.foreignKeys[constraintName].deleteRule = prop.deleteRule || (cascade ? 'cascade' : 'set null');
123
- }
124
- if (prop.updateRule) {
125
- this.foreignKeys[constraintName].updateRule = prop.updateRule || 'cascade';
126
- }
127
- if ((prop.cascade.includes(core_1.Cascade.PERSIST) || prop.cascade.includes(core_1.Cascade.ALL))) {
128
- const hasCascadePath = Object.values(this.foreignKeys).some(fk => {
129
- return fk.constraintName !== constraintName
130
- && ((fk.updateRule && fk.updateRule !== 'no action') || (fk.deleteRule && fk.deleteRule !== 'no action'))
131
- && fk.referencedTableName === this.foreignKeys[constraintName].referencedTableName;
132
- });
133
- if (!hasCascadePath || this.platform.supportsMultipleCascadePaths()) {
134
- this.foreignKeys[constraintName].updateRule ??= 'cascade';
112
+ if (prop.createForeignKeyConstraint) {
113
+ this.foreignKeys[constraintName] = {
114
+ constraintName,
115
+ columnNames: prop.fieldNames,
116
+ localTableName: this.getShortestName(),
117
+ referencedColumnNames: prop.referencedColumnNames,
118
+ referencedTableName: schema ? `${schema}.${prop.referencedTableName}` : prop.referencedTableName,
119
+ };
120
+ const cascade = prop.cascade.includes(core_1.Cascade.REMOVE) || prop.cascade.includes(core_1.Cascade.ALL);
121
+ if (prop.deleteRule || cascade || prop.nullable) {
122
+ this.foreignKeys[constraintName].deleteRule = prop.deleteRule || (cascade ? 'cascade' : 'set null');
123
+ }
124
+ if (prop.updateRule) {
125
+ this.foreignKeys[constraintName].updateRule = prop.updateRule || 'cascade';
126
+ }
127
+ if ((prop.cascade.includes(core_1.Cascade.PERSIST) || prop.cascade.includes(core_1.Cascade.ALL))) {
128
+ const hasCascadePath = Object.values(this.foreignKeys).some(fk => {
129
+ return fk.constraintName !== constraintName
130
+ && ((fk.updateRule && fk.updateRule !== 'no action') || (fk.deleteRule && fk.deleteRule !== 'no action'))
131
+ && fk.referencedTableName === this.foreignKeys[constraintName].referencedTableName;
132
+ });
133
+ if (!hasCascadePath || this.platform.supportsMultipleCascadePaths()) {
134
+ this.foreignKeys[constraintName].updateRule ??= 'cascade';
135
+ }
136
+ }
137
+ if (prop.deferMode) {
138
+ this.foreignKeys[constraintName].deferMode = prop.deferMode;
135
139
  }
136
- }
137
- if (prop.deferMode) {
138
- this.foreignKeys[constraintName].deferMode = prop.deferMode;
139
140
  }
140
141
  }
141
142
  if (prop.index) {
@@ -268,7 +268,7 @@ class SchemaComparator {
268
268
  }
269
269
  for (const toConstraint of Object.values(toForeignKeys)) {
270
270
  tableDifferences.addedForeignKeys[toConstraint.constraintName] = toConstraint;
271
- this.log(`FK constraint ${toConstraint.constraintName} added from table ${tableDifferences.name}`, { constraint: toConstraint });
271
+ this.log(`FK constraint ${toConstraint.constraintName} added to table ${tableDifferences.name}`, { constraint: toConstraint });
272
272
  changes++;
273
273
  }
274
274
  return changes ? tableDifferences : false;
@@ -321,7 +321,7 @@ class SchemaHelper {
321
321
  });
322
322
  }
323
323
  createForeignKey(table, foreignKey, schema) {
324
- if (!this.options.createForeignKeyConstraints || !foreignKey.createForeignKeyConstraint) {
324
+ if (!this.options.createForeignKeyConstraints) {
325
325
  return;
326
326
  }
327
327
  const builder = table
package/typings.d.ts CHANGED
@@ -60,7 +60,6 @@ export interface ForeignKey {
60
60
  updateRule?: string;
61
61
  deleteRule?: string;
62
62
  deferMode?: DeferMode;
63
- createForeignKeyConstraint: boolean;
64
63
  }
65
64
  export interface IndexDef {
66
65
  columnNames: string[];