@mikro-orm/knex 6.4.3-dev.12 → 6.4.3-dev.14

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.
@@ -2,4 +2,5 @@ import type { Dictionary } from '@mikro-orm/core';
2
2
  import { MonkeyPatchable } from '../../MonkeyPatchable';
3
3
  export declare class SqliteTableCompiler extends MonkeyPatchable.Sqlite3DialectTableCompiler {
4
4
  foreign(this: any, foreignInfo: Dictionary): void;
5
+ foreignKeys(this: any): string;
5
6
  }
@@ -41,5 +41,31 @@ class SqliteTableCompiler extends MonkeyPatchable_1.MonkeyPatchable.Sqlite3Diale
41
41
  });
42
42
  }
43
43
  }
44
+ foreignKeys() {
45
+ let sql = '';
46
+ const foreignKeys = (this.grouped.alterTable || []).filter((o) => o.method === 'foreign');
47
+ for (let i = 0, l = foreignKeys.length; i < l; i++) {
48
+ const foreign = foreignKeys[i].args[0];
49
+ const column = this.formatter.columnize(foreign.column);
50
+ const references = this.formatter.columnize(foreign.references);
51
+ const foreignTable = this.formatter.wrap(foreign.inTable);
52
+ /* istanbul ignore next */
53
+ let constraintName = foreign.keyName || '';
54
+ if (constraintName) {
55
+ constraintName = ' constraint ' + this.formatter.wrap(constraintName);
56
+ }
57
+ sql += `,${constraintName} foreign key(${column}) references ${foreignTable}(${references})`;
58
+ if (foreign.onDelete) {
59
+ sql += ` on delete ${foreign.onDelete}`;
60
+ }
61
+ if (foreign.onUpdate) {
62
+ sql += ` on update ${foreign.onUpdate}`;
63
+ }
64
+ if (foreign.deferrable) {
65
+ sql += ` deferrable initially ${foreign.deferrable}`;
66
+ }
67
+ }
68
+ return sql;
69
+ }
44
70
  }
45
71
  exports.SqliteTableCompiler = SqliteTableCompiler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.4.3-dev.12",
3
+ "version": "6.4.3-dev.14",
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.4.2"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.4.3-dev.12",
69
+ "@mikro-orm/core": "6.4.3-dev.14",
70
70
  "better-sqlite3": "*",
71
71
  "libsql": "*",
72
72
  "mariadb": "*"