@mikro-orm/knex 6.1.13-dev.3 → 6.1.13-dev.31

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.
Files changed (50) hide show
  1. package/AbstractSqlConnection.js +7 -1
  2. package/AbstractSqlDriver.d.ts +5 -5
  3. package/AbstractSqlDriver.js +18 -9
  4. package/MonkeyPatchable.d.ts +5 -0
  5. package/MonkeyPatchable.js +15 -0
  6. package/README.md +17 -11
  7. package/SqlEntityManager.d.ts +1 -1
  8. package/SqlEntityManager.js +1 -2
  9. package/dialects/index.d.ts +2 -0
  10. package/dialects/index.js +18 -0
  11. package/dialects/mssql/MsSqlColumnCompiler.d.ts +4 -0
  12. package/dialects/mssql/MsSqlColumnCompiler.js +10 -0
  13. package/dialects/mssql/MsSqlKnexDialect.d.ts +6 -0
  14. package/dialects/mssql/MsSqlKnexDialect.js +22 -0
  15. package/dialects/mssql/MsSqlQueryCompiler.d.ts +12 -0
  16. package/dialects/mssql/MsSqlQueryCompiler.js +94 -0
  17. package/dialects/mssql/MsSqlTableCompiler.d.ts +9 -0
  18. package/dialects/mssql/MsSqlTableCompiler.js +40 -0
  19. package/dialects/mssql/index.d.ts +1 -0
  20. package/dialects/mssql/index.js +17 -0
  21. package/dialects/sqlite/BaseSqliteConnection.d.ts +10 -0
  22. package/dialects/sqlite/BaseSqliteConnection.js +56 -0
  23. package/dialects/sqlite/BaseSqlitePlatform.d.ts +49 -0
  24. package/dialects/sqlite/BaseSqlitePlatform.js +78 -0
  25. package/dialects/sqlite/BaseSqliteSchemaHelper.d.ts +27 -0
  26. package/dialects/sqlite/BaseSqliteSchemaHelper.js +172 -0
  27. package/dialects/sqlite/BetterSqliteKnexDialect.d.ts +5 -0
  28. package/dialects/sqlite/BetterSqliteKnexDialect.js +15 -0
  29. package/dialects/sqlite/LibSqlKnexDialect.d.ts +6 -0
  30. package/dialects/sqlite/LibSqlKnexDialect.js +18 -0
  31. package/dialects/sqlite/SqliteKnexDialect.d.ts +8 -0
  32. package/dialects/sqlite/SqliteKnexDialect.js +67 -0
  33. package/dialects/sqlite/SqliteTableCompiler.d.ts +5 -0
  34. package/dialects/sqlite/SqliteTableCompiler.js +45 -0
  35. package/dialects/sqlite/index.d.ts +7 -0
  36. package/dialects/sqlite/index.js +23 -0
  37. package/index.d.ts +1 -0
  38. package/index.js +1 -0
  39. package/index.mjs +10 -0
  40. package/package.json +2 -2
  41. package/query/QueryBuilder.d.ts +59 -41
  42. package/query/QueryBuilder.js +64 -26
  43. package/query/QueryBuilderHelper.js +2 -1
  44. package/schema/DatabaseTable.js +20 -2
  45. package/schema/SchemaComparator.js +15 -2
  46. package/schema/SchemaHelper.d.ts +5 -1
  47. package/schema/SchemaHelper.js +20 -2
  48. package/schema/SqlSchemaGenerator.d.ts +12 -4
  49. package/schema/SqlSchemaGenerator.js +53 -28
  50. package/typings.d.ts +2 -1
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseSqlitePlatform = void 0;
4
+ const core_1 = require("@mikro-orm/core");
5
+ const AbstractSqlPlatform_1 = require("../../AbstractSqlPlatform");
6
+ class BaseSqlitePlatform extends AbstractSqlPlatform_1.AbstractSqlPlatform {
7
+ usesDefaultKeyword() {
8
+ return false;
9
+ }
10
+ usesReturningStatement() {
11
+ return true;
12
+ }
13
+ getCurrentTimestampSQL(length) {
14
+ return super.getCurrentTimestampSQL(0);
15
+ }
16
+ getDateTimeTypeDeclarationSQL(column) {
17
+ return 'datetime';
18
+ }
19
+ getEnumTypeDeclarationSQL(column) {
20
+ if (column.items?.every(item => core_1.Utils.isString(item))) {
21
+ return 'text';
22
+ }
23
+ /* istanbul ignore next */
24
+ return this.getTinyIntTypeDeclarationSQL(column);
25
+ }
26
+ getTinyIntTypeDeclarationSQL(column) {
27
+ return this.getIntegerTypeDeclarationSQL(column);
28
+ }
29
+ getSmallIntTypeDeclarationSQL(column) {
30
+ return this.getIntegerTypeDeclarationSQL(column);
31
+ }
32
+ getIntegerTypeDeclarationSQL(column) {
33
+ return 'integer';
34
+ }
35
+ getFloatDeclarationSQL() {
36
+ return 'real';
37
+ }
38
+ getBooleanTypeDeclarationSQL() {
39
+ return 'integer';
40
+ }
41
+ getVarcharTypeDeclarationSQL(column) {
42
+ return 'text';
43
+ }
44
+ convertsJsonAutomatically() {
45
+ return false;
46
+ }
47
+ allowsComparingTuples() {
48
+ return false;
49
+ }
50
+ /**
51
+ * This is used to narrow the value of Date properties as they will be stored as timestamps in sqlite.
52
+ * We use this method to convert Dates to timestamps when computing the changeset, so we have the right
53
+ * data type in the payload as well as in original entity data. Without that, we would end up with diffs
54
+ * including all Date properties, as we would be comparing Date object with timestamp.
55
+ */
56
+ processDateProperty(value) {
57
+ if (value instanceof Date) {
58
+ return +value;
59
+ }
60
+ return value;
61
+ }
62
+ getIndexName(tableName, columns, type) {
63
+ if (type === 'primary') {
64
+ return this.getDefaultPrimaryName(tableName, columns);
65
+ }
66
+ return super.getIndexName(tableName, columns, type);
67
+ }
68
+ getDefaultPrimaryName(tableName, columns) {
69
+ return 'primary';
70
+ }
71
+ supportsDownMigrations() {
72
+ return false;
73
+ }
74
+ getFullTextWhereClause() {
75
+ return `:column: match :query`;
76
+ }
77
+ }
78
+ exports.BaseSqlitePlatform = BaseSqlitePlatform;
@@ -0,0 +1,27 @@
1
+ import type { Connection, Dictionary } from '@mikro-orm/core';
2
+ import type { AbstractSqlConnection } from '../../AbstractSqlConnection';
3
+ import { SchemaHelper } from '../../schema/SchemaHelper';
4
+ import type { CheckDef, Column, IndexDef } from '../../typings';
5
+ export declare abstract class BaseSqliteSchemaHelper extends SchemaHelper {
6
+ disableForeignKeysSQL(): string;
7
+ enableForeignKeysSQL(): string;
8
+ supportsSchemaConstraints(): boolean;
9
+ getListTablesSQL(): string;
10
+ getDropDatabaseSQL(name: string): string;
11
+ getDropColumnsSQL(tableName: string, columns: Column[], schemaName?: string): string;
12
+ private parseTableDefinition;
13
+ getColumns(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<any[]>;
14
+ getEnumDefinitions(connection: AbstractSqlConnection, checks: CheckDef[], tableName: string, schemaName: string): Promise<Dictionary<string[]>>;
15
+ getPrimaryKeys(connection: AbstractSqlConnection, indexes: IndexDef[], tableName: string, schemaName?: string): Promise<string[]>;
16
+ getIndexes(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<IndexDef[]>;
17
+ getChecks(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<CheckDef[]>;
18
+ getForeignKeysSQL(tableName: string): string;
19
+ mapForeignKeys(fks: any[], tableName: string): Dictionary;
20
+ getManagementDbName(): string;
21
+ getCreateDatabaseSQL(name: string): string;
22
+ databaseExists(connection: Connection, name: string): Promise<boolean>;
23
+ /**
24
+ * Implicit indexes will be ignored when diffing
25
+ */
26
+ isImplicitIndex(name: string): boolean;
27
+ }
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseSqliteSchemaHelper = void 0;
4
+ const SchemaHelper_1 = require("../../schema/SchemaHelper");
5
+ class BaseSqliteSchemaHelper extends SchemaHelper_1.SchemaHelper {
6
+ disableForeignKeysSQL() {
7
+ return 'pragma foreign_keys = off;';
8
+ }
9
+ enableForeignKeysSQL() {
10
+ return 'pragma foreign_keys = on;';
11
+ }
12
+ supportsSchemaConstraints() {
13
+ return false;
14
+ }
15
+ getListTablesSQL() {
16
+ return `select name as table_name from sqlite_master where type = 'table' and name != 'sqlite_sequence' and name != 'geometry_columns' and name != 'spatial_ref_sys' `
17
+ + `union all select name as table_name from sqlite_temp_master where type = 'table' order by name`;
18
+ }
19
+ getDropDatabaseSQL(name) {
20
+ if (name === ':memory:') {
21
+ return '';
22
+ }
23
+ /* istanbul ignore next */
24
+ return `drop database if exists ${this.platform.quoteIdentifier(name)}`;
25
+ }
26
+ getDropColumnsSQL(tableName, columns, schemaName) {
27
+ /* istanbul ignore next */
28
+ const name = this.platform.quoteIdentifier((schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName);
29
+ return columns.map(column => {
30
+ return `alter table ${name} drop column ${this.platform.quoteIdentifier(column.name)}`;
31
+ }).join(';\n');
32
+ }
33
+ parseTableDefinition(sql, cols) {
34
+ const columns = {};
35
+ // extract all columns definitions
36
+ let columnsDef = sql.replaceAll('\n', '').match(new RegExp(`create table [\`"']?.*?[\`"']? \\((.*)\\)`, 'i'))?.[1];
37
+ /* istanbul ignore else */
38
+ if (columnsDef) {
39
+ for (let i = cols.length - 1; i >= 0; i--) {
40
+ const col = cols[i];
41
+ const re = ` *, *[\`"']?${col.name}[\`"']? (.*)`;
42
+ const columnDef = columnsDef.match(new RegExp(re, 'i'));
43
+ /* istanbul ignore else */
44
+ if (columnDef) {
45
+ columns[col.name] = { name: col.name, definition: columnDef[1] };
46
+ columnsDef = columnsDef.substring(0, columnDef.index);
47
+ }
48
+ }
49
+ }
50
+ return columns;
51
+ }
52
+ async getColumns(connection, tableName, schemaName) {
53
+ const columns = await connection.execute(`pragma table_xinfo('${tableName}')`);
54
+ const sql = `select sql from sqlite_master where type = ? and name = ?`;
55
+ const tableDefinition = await connection.execute(sql, ['table', tableName], 'get');
56
+ const composite = columns.reduce((count, col) => count + (col.pk ? 1 : 0), 0) > 1;
57
+ // there can be only one, so naive check like this should be enough
58
+ const hasAutoincrement = tableDefinition.sql.toLowerCase().includes('autoincrement');
59
+ const columnDefinitions = this.parseTableDefinition(tableDefinition.sql, columns);
60
+ return columns.map(col => {
61
+ const mappedType = connection.getPlatform().getMappedType(col.type);
62
+ let generated;
63
+ if (col.hidden > 1) {
64
+ /* istanbul ignore next */
65
+ const storage = col.hidden === 2 ? 'virtual' : 'stored';
66
+ const re = `(generated always)? as \\((.*)\\)( ${storage})?$`;
67
+ const match = columnDefinitions[col.name].definition.match(re);
68
+ if (match) {
69
+ generated = `${match[2]} ${storage}`;
70
+ }
71
+ }
72
+ return {
73
+ name: col.name,
74
+ type: col.type,
75
+ default: col.dflt_value,
76
+ nullable: !col.notnull,
77
+ primary: !!col.pk,
78
+ mappedType,
79
+ unsigned: false,
80
+ autoincrement: !composite && col.pk && this.platform.isNumericColumn(mappedType) && hasAutoincrement,
81
+ generated,
82
+ };
83
+ });
84
+ }
85
+ async getEnumDefinitions(connection, checks, tableName, schemaName) {
86
+ const sql = `select sql from sqlite_master where type = ? and name = ?`;
87
+ const tableDefinition = await connection.execute(sql, ['table', tableName], 'get');
88
+ const checkConstraints = [...tableDefinition.sql.match(/[`["'][^`\]"']+[`\]"'] text check \(.*?\)/gi) ?? []];
89
+ return checkConstraints.reduce((o, item) => {
90
+ // check constraints are defined as (note that last closing paren is missing):
91
+ // `type` text check (`type` in ('local', 'global')
92
+ const match = item.match(/[`["']([^`\]"']+)[`\]"'] text check \(.* \((.*)\)/i);
93
+ /* istanbul ignore else */
94
+ if (match) {
95
+ o[match[1]] = match[2].split(',').map((item) => item.trim().match(/^\(?'(.*)'/)[1]);
96
+ }
97
+ return o;
98
+ }, {});
99
+ }
100
+ async getPrimaryKeys(connection, indexes, tableName, schemaName) {
101
+ const sql = `pragma table_info(\`${tableName}\`)`;
102
+ const cols = await connection.execute(sql);
103
+ return cols.filter(col => !!col.pk).map(col => col.name);
104
+ }
105
+ async getIndexes(connection, tableName, schemaName) {
106
+ const sql = `pragma table_info(\`${tableName}\`)`;
107
+ const cols = await connection.execute(sql);
108
+ const indexes = await connection.execute(`pragma index_list(\`${tableName}\`)`);
109
+ const ret = [];
110
+ for (const col of cols.filter(c => c.pk)) {
111
+ ret.push({
112
+ columnNames: [col.name],
113
+ keyName: 'primary',
114
+ constraint: true,
115
+ unique: true,
116
+ primary: true,
117
+ });
118
+ }
119
+ for (const index of indexes.filter(index => !this.isImplicitIndex(index.name))) {
120
+ const res = await connection.execute(`pragma index_info(\`${index.name}\`)`);
121
+ ret.push(...res.map(row => ({
122
+ columnNames: [row.name],
123
+ keyName: index.name,
124
+ unique: !!index.unique,
125
+ constraint: !!index.unique,
126
+ primary: false,
127
+ })));
128
+ }
129
+ return this.mapIndexes(ret);
130
+ }
131
+ async getChecks(connection, tableName, schemaName) {
132
+ // Not supported at the moment.
133
+ return [];
134
+ }
135
+ getForeignKeysSQL(tableName) {
136
+ return `pragma foreign_key_list(\`${tableName}\`)`;
137
+ }
138
+ mapForeignKeys(fks, tableName) {
139
+ return fks.reduce((ret, fk) => {
140
+ ret[fk.from] = {
141
+ constraintName: this.platform.getIndexName(tableName, [fk.from], 'foreign'),
142
+ columnName: fk.from,
143
+ columnNames: [fk.from],
144
+ localTableName: tableName,
145
+ referencedTableName: fk.table,
146
+ referencedColumnName: fk.to,
147
+ referencedColumnNames: [fk.to],
148
+ updateRule: fk.on_update.toLowerCase(),
149
+ deleteRule: fk.on_delete.toLowerCase(),
150
+ };
151
+ return ret;
152
+ }, {});
153
+ }
154
+ getManagementDbName() {
155
+ return '';
156
+ }
157
+ getCreateDatabaseSQL(name) {
158
+ return '';
159
+ }
160
+ async databaseExists(connection, name) {
161
+ const tables = await connection.execute(this.getListTablesSQL());
162
+ return tables.length > 0;
163
+ }
164
+ /**
165
+ * Implicit indexes will be ignored when diffing
166
+ */
167
+ isImplicitIndex(name) {
168
+ // Ignore indexes with reserved names, e.g. autoindexes
169
+ return name.startsWith('sqlite_');
170
+ }
171
+ }
172
+ exports.BaseSqliteSchemaHelper = BaseSqliteSchemaHelper;
@@ -0,0 +1,5 @@
1
+ import { MonkeyPatchable } from '../../MonkeyPatchable';
2
+ export declare class BetterSqliteKnexDialect extends MonkeyPatchable.BetterSqlite3Dialect {
3
+ _driver(): any;
4
+ tableCompiler(): any;
5
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BetterSqliteKnexDialect = void 0;
4
+ const SqliteTableCompiler_1 = require("./SqliteTableCompiler");
5
+ const MonkeyPatchable_1 = require("../../MonkeyPatchable");
6
+ class BetterSqliteKnexDialect extends MonkeyPatchable_1.MonkeyPatchable.BetterSqlite3Dialect {
7
+ _driver() {
8
+ return require('better-sqlite3');
9
+ }
10
+ tableCompiler() {
11
+ // eslint-disable-next-line prefer-rest-params
12
+ return new SqliteTableCompiler_1.SqliteTableCompiler(this, ...arguments);
13
+ }
14
+ }
15
+ exports.BetterSqliteKnexDialect = BetterSqliteKnexDialect;
@@ -0,0 +1,6 @@
1
+ import { MonkeyPatchable } from '../../MonkeyPatchable';
2
+ export declare class LibSqlKnexDialect extends MonkeyPatchable.BetterSqlite3Dialect {
3
+ get driverName(): string;
4
+ _driver(): any;
5
+ tableCompiler(): any;
6
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LibSqlKnexDialect = void 0;
4
+ const SqliteTableCompiler_1 = require("./SqliteTableCompiler");
5
+ const MonkeyPatchable_1 = require("../../MonkeyPatchable");
6
+ class LibSqlKnexDialect extends MonkeyPatchable_1.MonkeyPatchable.BetterSqlite3Dialect {
7
+ get driverName() {
8
+ return 'libsql';
9
+ }
10
+ _driver() {
11
+ return require('libsql');
12
+ }
13
+ tableCompiler() {
14
+ // eslint-disable-next-line prefer-rest-params
15
+ return new SqliteTableCompiler_1.SqliteTableCompiler(this, ...arguments);
16
+ }
17
+ }
18
+ exports.LibSqlKnexDialect = LibSqlKnexDialect;
@@ -0,0 +1,8 @@
1
+ import { MonkeyPatchable } from '../../MonkeyPatchable';
2
+ export declare class SqliteKnexDialect extends MonkeyPatchable.Sqlite3Dialect {
3
+ tableCompiler(): any;
4
+ processResponse(obj: any, runner: any): any;
5
+ _query(connection: any, obj: any): Promise<unknown>;
6
+ private getCallMethod;
7
+ private isRunQuery;
8
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SqliteKnexDialect = void 0;
4
+ const SqliteTableCompiler_1 = require("./SqliteTableCompiler");
5
+ const MonkeyPatchable_1 = require("../../MonkeyPatchable");
6
+ class SqliteKnexDialect extends MonkeyPatchable_1.MonkeyPatchable.Sqlite3Dialect {
7
+ tableCompiler() {
8
+ // eslint-disable-next-line prefer-rest-params
9
+ return new SqliteTableCompiler_1.SqliteTableCompiler(this, ...arguments);
10
+ }
11
+ processResponse(obj, runner) {
12
+ if (obj.method === 'raw' && this.isRunQuery(obj.sql)) {
13
+ return obj.response ?? obj.context;
14
+ }
15
+ return super.processResponse(obj, runner);
16
+ }
17
+ _query(connection, obj) {
18
+ const callMethod = this.getCallMethod(obj);
19
+ return new Promise((resolve, reject) => {
20
+ /* istanbul ignore if */
21
+ if (!connection?.[callMethod]) {
22
+ return reject(new Error(`Error calling ${callMethod} on connection.`));
23
+ }
24
+ connection[callMethod](obj.sql, obj.bindings, function (err, response) {
25
+ if (err) {
26
+ return reject(err);
27
+ }
28
+ obj.response = response;
29
+ obj.context = this;
30
+ return resolve(obj);
31
+ });
32
+ });
33
+ }
34
+ getCallMethod(obj) {
35
+ if (obj.method === 'raw') {
36
+ const query = obj.sql.trim().toLowerCase();
37
+ if ((query.startsWith('insert into') || query.startsWith('update ')) && query.includes(' returning ')) {
38
+ return 'all';
39
+ }
40
+ if (this.isRunQuery(query)) {
41
+ return 'run';
42
+ }
43
+ }
44
+ /* istanbul ignore next */
45
+ switch (obj.method) {
46
+ case 'insert':
47
+ case 'update':
48
+ return obj.returning ? 'all' : 'run';
49
+ case 'counter':
50
+ case 'del':
51
+ return 'run';
52
+ default:
53
+ return 'all';
54
+ }
55
+ }
56
+ isRunQuery(query) {
57
+ query = query.trim().toLowerCase();
58
+ if ((query.startsWith('insert into') || query.startsWith('update ')) && query.includes(' returning ')) {
59
+ return false;
60
+ }
61
+ return query.startsWith('insert into') ||
62
+ query.startsWith('update') ||
63
+ query.startsWith('delete') ||
64
+ query.startsWith('truncate');
65
+ }
66
+ }
67
+ exports.SqliteKnexDialect = SqliteKnexDialect;
@@ -0,0 +1,5 @@
1
+ import type { Dictionary } from '@mikro-orm/core';
2
+ import { MonkeyPatchable } from '../../MonkeyPatchable';
3
+ export declare class SqliteTableCompiler extends MonkeyPatchable.Sqlite3DialectTableCompiler {
4
+ foreign(this: any, foreignInfo: Dictionary): void;
5
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SqliteTableCompiler = void 0;
4
+ const MonkeyPatchable_1 = require("../../MonkeyPatchable");
5
+ class SqliteTableCompiler extends MonkeyPatchable_1.MonkeyPatchable.Sqlite3DialectTableCompiler {
6
+ foreign(foreignInfo) {
7
+ foreignInfo.column = Array.isArray(foreignInfo.column)
8
+ ? foreignInfo.column
9
+ : [foreignInfo.column];
10
+ foreignInfo.column = foreignInfo.column.map((column) => this.client.customWrapIdentifier(column, (a) => a));
11
+ foreignInfo.inTable = this.client.customWrapIdentifier(foreignInfo.inTable, (a) => a);
12
+ foreignInfo.references = Array.isArray(foreignInfo.references)
13
+ ? foreignInfo.references
14
+ : [foreignInfo.references];
15
+ foreignInfo.references = foreignInfo.references.map((column) => this.client.customWrapIdentifier(column, (a) => a));
16
+ // quoted versions
17
+ const column = this.formatter.columnize(foreignInfo.column);
18
+ const inTable = this.formatter.columnize(foreignInfo.inTable);
19
+ const references = this.formatter.columnize(foreignInfo.references);
20
+ const keyName = this.formatter.columnize(foreignInfo.keyName);
21
+ const addColumnQuery = this.sequence.find((query) => query.sql.includes(`add column ${column[0]}`));
22
+ // no need for temp tables if we just add a column
23
+ if (addColumnQuery) {
24
+ /* istanbul ignore next */
25
+ const onUpdate = foreignInfo.onUpdate ? ` on update ${foreignInfo.onUpdate}` : '';
26
+ /* istanbul ignore next */
27
+ const onDelete = foreignInfo.onDelete ? ` on delete ${foreignInfo.onDelete}` : '';
28
+ addColumnQuery.sql += ` constraint ${keyName} references ${inTable} (${references})${onUpdate}${onDelete}`;
29
+ return;
30
+ }
31
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
32
+ const compiler = this;
33
+ if (this.method !== 'create' && this.method !== 'createIfNot') {
34
+ this.pushQuery({
35
+ sql: `PRAGMA table_info(${this.tableName()})`,
36
+ statementsProducer(pragma, connection) {
37
+ return compiler.client
38
+ .ddl(compiler, pragma, connection)
39
+ .foreign(foreignInfo);
40
+ },
41
+ });
42
+ }
43
+ }
44
+ }
45
+ exports.SqliteTableCompiler = SqliteTableCompiler;
@@ -0,0 +1,7 @@
1
+ export * from './BaseSqliteConnection';
2
+ export * from './BaseSqlitePlatform';
3
+ export * from './BaseSqliteSchemaHelper';
4
+ export * from './SqliteTableCompiler';
5
+ export * from './BetterSqliteKnexDialect';
6
+ export * from './LibSqlKnexDialect';
7
+ export * from './SqliteKnexDialect';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./BaseSqliteConnection"), exports);
18
+ __exportStar(require("./BaseSqlitePlatform"), exports);
19
+ __exportStar(require("./BaseSqliteSchemaHelper"), exports);
20
+ __exportStar(require("./SqliteTableCompiler"), exports);
21
+ __exportStar(require("./BetterSqliteKnexDialect"), exports);
22
+ __exportStar(require("./LibSqlKnexDialect"), exports);
23
+ __exportStar(require("./SqliteKnexDialect"), exports);
package/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export * from './SqlEntityManager';
10
10
  export * from './SqlEntityRepository';
11
11
  export * from './query';
12
12
  export * from './schema';
13
+ export * from './dialects';
13
14
  export * from './typings';
14
15
  export { SqlEntityManager as EntityManager } from './SqlEntityManager';
15
16
  export { SqlEntityRepository as EntityRepository } from './SqlEntityRepository';
package/index.js CHANGED
@@ -28,6 +28,7 @@ __exportStar(require("./SqlEntityManager"), exports);
28
28
  __exportStar(require("./SqlEntityRepository"), exports);
29
29
  __exportStar(require("./query"), exports);
30
30
  __exportStar(require("./schema"), exports);
31
+ __exportStar(require("./dialects"), exports);
31
32
  __exportStar(require("./typings"), exports);
32
33
  var SqlEntityManager_1 = require("./SqlEntityManager");
33
34
  Object.defineProperty(exports, "EntityManager", { enumerable: true, get: function () { return SqlEntityManager_1.SqlEntityManager; } });
package/index.mjs CHANGED
@@ -17,10 +17,14 @@ export const ArrayCollection = mod.ArrayCollection;
17
17
  export const ArrayCriteriaNode = mod.ArrayCriteriaNode;
18
18
  export const ArrayType = mod.ArrayType;
19
19
  export const BaseEntity = mod.BaseEntity;
20
+ export const BaseSqliteConnection = mod.BaseSqliteConnection;
21
+ export const BaseSqlitePlatform = mod.BaseSqlitePlatform;
22
+ export const BaseSqliteSchemaHelper = mod.BaseSqliteSchemaHelper;
20
23
  export const BeforeCreate = mod.BeforeCreate;
21
24
  export const BeforeDelete = mod.BeforeDelete;
22
25
  export const BeforeUpdate = mod.BeforeUpdate;
23
26
  export const BeforeUpsert = mod.BeforeUpsert;
27
+ export const BetterSqliteKnexDialect = mod.BetterSqliteKnexDialect;
24
28
  export const BigIntType = mod.BigIntType;
25
29
  export const BlobType = mod.BlobType;
26
30
  export const BooleanType = mod.BooleanType;
@@ -56,6 +60,7 @@ export const DateType = mod.DateType;
56
60
  export const DeadlockException = mod.DeadlockException;
57
61
  export const DecimalType = mod.DecimalType;
58
62
  export const DefaultLogger = mod.DefaultLogger;
63
+ export const DeferMode = mod.DeferMode;
59
64
  export const DoubleType = mod.DoubleType;
60
65
  export const DriverException = mod.DriverException;
61
66
  export const EagerProps = mod.EagerProps;
@@ -107,6 +112,7 @@ export const JoinType = mod.JoinType;
107
112
  export const JsonProperty = mod.JsonProperty;
108
113
  export const JsonType = mod.JsonType;
109
114
  export const Knex = mod.Knex;
115
+ export const LibSqlKnexDialect = mod.LibSqlKnexDialect;
110
116
  export const LoadStrategy = mod.LoadStrategy;
111
117
  export const LockMode = mod.LockMode;
112
118
  export const LockWaitTimeoutException = mod.LockWaitTimeoutException;
@@ -122,6 +128,7 @@ export const MetadataValidator = mod.MetadataValidator;
122
128
  export const MikroORM = mod.MikroORM;
123
129
  export const MongoNamingStrategy = mod.MongoNamingStrategy;
124
130
  export const MonkeyPatchable = mod.MonkeyPatchable;
131
+ export const MsSqlKnexDialect = mod.MsSqlKnexDialect;
125
132
  export const NodeState = mod.NodeState;
126
133
  export const NonUniqueFieldNameException = mod.NonUniqueFieldNameException;
127
134
  export const NotFoundError = mod.NotFoundError;
@@ -140,6 +147,7 @@ export const OptionalProps = mod.OptionalProps;
140
147
  export const PlainObject = mod.PlainObject;
141
148
  export const Platform = mod.Platform;
142
149
  export const PopulateHint = mod.PopulateHint;
150
+ export const PopulatePath = mod.PopulatePath;
143
151
  export const PrimaryKey = mod.PrimaryKey;
144
152
  export const PrimaryKeyProp = mod.PrimaryKeyProp;
145
153
  export const Property = mod.Property;
@@ -172,6 +180,8 @@ export const SmallIntType = mod.SmallIntType;
172
180
  export const SqlEntityManager = mod.SqlEntityManager;
173
181
  export const SqlEntityRepository = mod.SqlEntityRepository;
174
182
  export const SqlSchemaGenerator = mod.SqlSchemaGenerator;
183
+ export const SqliteKnexDialect = mod.SqliteKnexDialect;
184
+ export const SqliteTableCompiler = mod.SqliteTableCompiler;
175
185
  export const StringType = mod.StringType;
176
186
  export const SyntaxErrorException = mod.SyntaxErrorException;
177
187
  export const TableExistsException = mod.TableExistsException;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.1.13-dev.3",
3
+ "version": "6.1.13-dev.31",
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,6 +66,6 @@
66
66
  "@mikro-orm/core": "^6.1.12"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.1.13-dev.3"
69
+ "@mikro-orm/core": "6.1.13-dev.31"
70
70
  }
71
71
  }