@mikro-orm/knex 6.6.11-dev.0 → 6.6.11-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.
@@ -1,6 +1,6 @@
1
1
  import type { Knex } from 'knex';
2
2
  import type { CheckDef, Column, IndexDef, TableDifference, Table, ForeignKey, MySqlTableBuilder } from '../../typings';
3
- import { type Dictionary, type Type } from '@mikro-orm/core';
3
+ import { type Dictionary, type Transaction, type Type } from '@mikro-orm/core';
4
4
  import type { AbstractSqlConnection } from '../../AbstractSqlConnection';
5
5
  import { SchemaHelper } from '../../schema/SchemaHelper';
6
6
  import type { DatabaseSchema } from '../../schema/DatabaseSchema';
@@ -17,11 +17,11 @@ export declare class MySqlSchemaHelper extends SchemaHelper {
17
17
  enableForeignKeysSQL(): string;
18
18
  finalizeTable(table: Knex.CreateTableBuilder, charset: string, collate?: string): void;
19
19
  getListTablesSQL(): string;
20
- loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[]): Promise<void>;
21
- getAllIndexes(connection: AbstractSqlConnection, tables: Table[]): Promise<Dictionary<IndexDef[]>>;
22
- getAllColumns(connection: AbstractSqlConnection, tables: Table[]): Promise<Dictionary<Column[]>>;
23
- getAllChecks(connection: AbstractSqlConnection, tables: Table[]): Promise<Dictionary<CheckDef[]>>;
24
- getAllForeignKeys(connection: AbstractSqlConnection, tables: Table[]): Promise<Dictionary<Dictionary<ForeignKey>>>;
20
+ loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[], schemas?: string[], ctx?: Transaction): Promise<void>;
21
+ getAllIndexes(connection: AbstractSqlConnection, tables: Table[], ctx?: Transaction): Promise<Dictionary<IndexDef[]>>;
22
+ getAllColumns(connection: AbstractSqlConnection, tables: Table[], ctx?: Transaction): Promise<Dictionary<Column[]>>;
23
+ getAllChecks(connection: AbstractSqlConnection, tables: Table[], ctx?: Transaction): Promise<Dictionary<CheckDef[]>>;
24
+ getAllForeignKeys(connection: AbstractSqlConnection, tables: Table[], ctx?: Transaction): Promise<Dictionary<Dictionary<ForeignKey>>>;
25
25
  getPreAlterTable(tableDiff: TableDifference, safe: boolean): string;
26
26
  createTableColumn(table: MySqlTableBuilder, column: Column, fromTable: DatabaseTable, changedProperties?: Set<string>, alter?: boolean): Knex.ColumnBuilder | undefined;
27
27
  configureColumnDefault(column: Column, col: Knex.ColumnBuilder, knex: Knex, changedProperties?: Set<string>): Knex.ColumnBuilder;
@@ -30,7 +30,7 @@ export declare class MySqlSchemaHelper extends SchemaHelper {
30
30
  getChangeColumnCommentSQL(tableName: string, to: Column, schemaName?: string): string;
31
31
  private getColumnDeclarationSQL;
32
32
  getForeignKeysSQL(tableName: string, schemaName?: string): string;
33
- getAllEnumDefinitions(connection: AbstractSqlConnection, tables: Table[]): Promise<Dictionary<Dictionary<string[]>>>;
33
+ getAllEnumDefinitions(connection: AbstractSqlConnection, tables: Table[], ctx?: Transaction): Promise<Dictionary<Dictionary<string[]>>>;
34
34
  private supportsCheckConstraints;
35
35
  protected getChecksSQL(tables: Table[]): string;
36
36
  getChecks(connection: AbstractSqlConnection, tableName: string, schemaName: string, columns?: Column[]): Promise<CheckDef[]>;
@@ -32,15 +32,15 @@ class MySqlSchemaHelper extends SchemaHelper_1.SchemaHelper {
32
32
  getListTablesSQL() {
33
33
  return `select table_name as table_name, nullif(table_schema, schema()) as schema_name, table_comment as table_comment from information_schema.tables where table_type = 'BASE TABLE' and table_schema = schema()`;
34
34
  }
35
- async loadInformationSchema(schema, connection, tables) {
35
+ async loadInformationSchema(schema, connection, tables, schemas, ctx) {
36
36
  if (tables.length === 0) {
37
37
  return;
38
38
  }
39
- const columns = await this.getAllColumns(connection, tables);
40
- const indexes = await this.getAllIndexes(connection, tables);
41
- const checks = await this.getAllChecks(connection, tables);
42
- const fks = await this.getAllForeignKeys(connection, tables);
43
- const enums = await this.getAllEnumDefinitions(connection, tables);
39
+ const columns = await this.getAllColumns(connection, tables, ctx);
40
+ const indexes = await this.getAllIndexes(connection, tables, ctx);
41
+ const checks = await this.getAllChecks(connection, tables, ctx);
42
+ const fks = await this.getAllForeignKeys(connection, tables, ctx);
43
+ const enums = await this.getAllEnumDefinitions(connection, tables, ctx);
44
44
  for (const t of tables) {
45
45
  const key = this.getTableKey(t);
46
46
  const table = schema.addTable(t.table_name, t.schema_name, t.table_comment);
@@ -48,12 +48,12 @@ class MySqlSchemaHelper extends SchemaHelper_1.SchemaHelper {
48
48
  table.init(columns[key], indexes[key], checks[key], pks, fks[key], enums[key]);
49
49
  }
50
50
  }
51
- async getAllIndexes(connection, tables) {
51
+ async getAllIndexes(connection, tables, ctx) {
52
52
  const sql = `select table_name as table_name, nullif(table_schema, schema()) as schema_name, index_name as index_name, non_unique as non_unique, column_name as column_name /*!80013 , expression as expression */
53
53
  from information_schema.statistics where table_schema = database()
54
54
  and table_name in (${tables.map(t => this.platform.quoteValue(t.table_name)).join(', ')})
55
55
  order by schema_name, table_name, index_name, seq_in_index`;
56
- const allIndexes = await connection.execute(sql);
56
+ const allIndexes = await connection.execute(sql, [], 'all', ctx);
57
57
  const ret = {};
58
58
  for (const index of allIndexes) {
59
59
  const key = this.getTableKey(index);
@@ -76,7 +76,7 @@ class MySqlSchemaHelper extends SchemaHelper_1.SchemaHelper {
76
76
  }
77
77
  return ret;
78
78
  }
79
- async getAllColumns(connection, tables) {
79
+ async getAllColumns(connection, tables, ctx) {
80
80
  const sql = `select table_name as table_name,
81
81
  nullif(table_schema, schema()) as schema_name,
82
82
  column_name as column_name,
@@ -93,7 +93,7 @@ class MySqlSchemaHelper extends SchemaHelper_1.SchemaHelper {
93
93
  ifnull(datetime_precision, character_maximum_length) length
94
94
  from information_schema.columns where table_schema = database() and table_name in (${tables.map(t => this.platform.quoteValue(t.table_name))})
95
95
  order by ordinal_position`;
96
- const allColumns = await connection.execute(sql);
96
+ const allColumns = await connection.execute(sql, [], 'all', ctx);
97
97
  const str = (val) => val != null ? '' + val : val;
98
98
  const extra = (val) => val.replace(/auto_increment|default_generated|(stored|virtual) generated/i, '').trim() || undefined;
99
99
  const ret = {};
@@ -125,13 +125,13 @@ class MySqlSchemaHelper extends SchemaHelper_1.SchemaHelper {
125
125
  }
126
126
  return ret;
127
127
  }
128
- async getAllChecks(connection, tables) {
128
+ async getAllChecks(connection, tables, ctx) {
129
129
  /* istanbul ignore next */
130
- if (!await this.supportsCheckConstraints(connection)) {
130
+ if (!await this.supportsCheckConstraints(connection, ctx)) {
131
131
  return {};
132
132
  }
133
133
  const sql = this.getChecksSQL(tables);
134
- const allChecks = await connection.execute(sql);
134
+ const allChecks = await connection.execute(sql, [], 'all', ctx);
135
135
  const ret = {};
136
136
  for (const check of allChecks) {
137
137
  const key = this.getTableKey(check);
@@ -145,14 +145,14 @@ class MySqlSchemaHelper extends SchemaHelper_1.SchemaHelper {
145
145
  }
146
146
  return ret;
147
147
  }
148
- async getAllForeignKeys(connection, tables) {
148
+ async getAllForeignKeys(connection, tables, ctx) {
149
149
  const sql = `select k.constraint_name as constraint_name, nullif(k.table_schema, schema()) as schema_name, k.table_name as table_name, k.column_name as column_name, k.referenced_table_name as referenced_table_name, k.referenced_column_name as referenced_column_name, c.update_rule as update_rule, c.delete_rule as delete_rule
150
150
  from information_schema.key_column_usage k
151
151
  inner join information_schema.referential_constraints c on c.constraint_name = k.constraint_name and c.table_name = k.table_name
152
152
  where k.table_name in (${tables.map(t => this.platform.quoteValue(t.table_name)).join(', ')})
153
153
  and k.table_schema = database() and c.constraint_schema = database() and k.referenced_column_name is not null
154
154
  order by constraint_name, k.ordinal_position`;
155
- const allFks = await connection.execute(sql);
155
+ const allFks = await connection.execute(sql, [], 'all', ctx);
156
156
  const ret = {};
157
157
  for (const fk of allFks) {
158
158
  const key = this.getTableKey(fk);
@@ -253,23 +253,23 @@ class MySqlSchemaHelper extends SchemaHelper_1.SchemaHelper {
253
253
  + `inner join information_schema.referential_constraints c on c.constraint_name = k.constraint_name and c.table_name = '${tableName}' `
254
254
  + `where k.table_name = '${tableName}' and k.table_schema = database() and c.constraint_schema = database() and k.referenced_column_name is not null`;
255
255
  }
256
- async getAllEnumDefinitions(connection, tables) {
256
+ async getAllEnumDefinitions(connection, tables, ctx) {
257
257
  const sql = `select column_name as column_name, column_type as column_type, table_name as table_name
258
258
  from information_schema.columns
259
259
  where data_type = 'enum' and table_name in (${tables.map(t => `'${t.table_name}'`).join(', ')}) and table_schema = database()`;
260
- const enums = await connection.execute(sql);
260
+ const enums = await connection.execute(sql, [], 'all', ctx);
261
261
  return enums.reduce((o, item) => {
262
262
  o[item.table_name] ??= {};
263
263
  o[item.table_name][item.column_name] = item.column_type.match(/enum\((.*)\)/)[1].split(',').map((item) => item.match(/'(.*)'/)[1]);
264
264
  return o;
265
265
  }, {});
266
266
  }
267
- async supportsCheckConstraints(connection) {
267
+ async supportsCheckConstraints(connection, ctx) {
268
268
  if (this._cache.supportsCheckConstraints != null) {
269
269
  return this._cache.supportsCheckConstraints;
270
270
  }
271
271
  const sql = `select 1 from information_schema.tables where table_name = 'CHECK_CONSTRAINTS' and table_schema = 'information_schema'`;
272
- const res = await connection.execute(sql);
272
+ const res = await connection.execute(sql, [], 'all', ctx);
273
273
  return this._cache.supportsCheckConstraints = res.length > 0;
274
274
  }
275
275
  getChecksSQL(tables) {
@@ -1,4 +1,4 @@
1
- import type { Connection, Dictionary } from '@mikro-orm/core';
1
+ import type { Connection, Dictionary, Transaction } from '@mikro-orm/core';
2
2
  import type { AbstractSqlConnection } from '../../AbstractSqlConnection';
3
3
  import { SchemaHelper } from '../../schema/SchemaHelper';
4
4
  import type { CheckDef, Column, IndexDef, TableDifference } from '../../typings';
@@ -10,10 +10,10 @@ export declare abstract class BaseSqliteSchemaHelper extends SchemaHelper {
10
10
  getDropDatabaseSQL(name: string): string;
11
11
  getDropColumnsSQL(tableName: string, columns: Column[], schemaName?: string): string;
12
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[]>;
13
+ getColumns(connection: AbstractSqlConnection, tableName: string, schemaName?: string, ctx?: Transaction): Promise<any[]>;
14
+ getEnumDefinitions(connection: AbstractSqlConnection, checks: CheckDef[], tableName: string, schemaName: string, ctx?: Transaction): Promise<Dictionary<string[]>>;
15
+ getPrimaryKeys(connection: AbstractSqlConnection, indexes: IndexDef[], tableName: string, schemaName?: string, ctx?: Transaction): Promise<string[]>;
16
+ getIndexes(connection: AbstractSqlConnection, tableName: string, schemaName?: string, ctx?: Transaction): Promise<IndexDef[]>;
17
17
  getChecks(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<CheckDef[]>;
18
18
  getForeignKeysSQL(tableName: string): string;
19
19
  mapForeignKeys(fks: any[], tableName: string): Dictionary;
@@ -49,10 +49,10 @@ class BaseSqliteSchemaHelper extends SchemaHelper_1.SchemaHelper {
49
49
  }
50
50
  return columns;
51
51
  }
52
- async getColumns(connection, tableName, schemaName) {
53
- const columns = await connection.execute(`pragma table_xinfo('${tableName}')`);
52
+ async getColumns(connection, tableName, schemaName, ctx) {
53
+ const columns = await connection.execute(`pragma table_xinfo('${tableName}')`, [], 'all', ctx);
54
54
  const sql = `select sql from sqlite_master where type = ? and name = ?`;
55
- const tableDefinition = await connection.execute(sql, ['table', tableName], 'get');
55
+ const tableDefinition = await connection.execute(sql, ['table', tableName], 'get', ctx);
56
56
  const composite = columns.reduce((count, col) => count + (col.pk ? 1 : 0), 0) > 1;
57
57
  // there can be only one, so naive check like this should be enough
58
58
  const hasAutoincrement = tableDefinition.sql.toLowerCase().includes('autoincrement');
@@ -82,9 +82,9 @@ class BaseSqliteSchemaHelper extends SchemaHelper_1.SchemaHelper {
82
82
  };
83
83
  });
84
84
  }
85
- async getEnumDefinitions(connection, checks, tableName, schemaName) {
85
+ async getEnumDefinitions(connection, checks, tableName, schemaName, ctx) {
86
86
  const sql = `select sql from sqlite_master where type = ? and name = ?`;
87
- const tableDefinition = await connection.execute(sql, ['table', tableName], 'get');
87
+ const tableDefinition = await connection.execute(sql, ['table', tableName], 'get', ctx);
88
88
  const checkConstraints = [...tableDefinition.sql.match(/[`["'][^`\]"']+[`\]"'] text check \(.*?\)/gi) ?? []];
89
89
  return checkConstraints.reduce((o, item) => {
90
90
  // check constraints are defined as (note that last closing paren is missing):
@@ -99,15 +99,15 @@ class BaseSqliteSchemaHelper extends SchemaHelper_1.SchemaHelper {
99
99
  return o;
100
100
  }, {});
101
101
  }
102
- async getPrimaryKeys(connection, indexes, tableName, schemaName) {
102
+ async getPrimaryKeys(connection, indexes, tableName, schemaName, ctx) {
103
103
  const sql = `pragma table_info(\`${tableName}\`)`;
104
- const cols = await connection.execute(sql);
104
+ const cols = await connection.execute(sql, [], 'all', ctx);
105
105
  return cols.filter(col => !!col.pk).map(col => col.name);
106
106
  }
107
- async getIndexes(connection, tableName, schemaName) {
107
+ async getIndexes(connection, tableName, schemaName, ctx) {
108
108
  const sql = `pragma table_info(\`${tableName}\`)`;
109
- const cols = await connection.execute(sql);
110
- const indexes = await connection.execute(`pragma index_list(\`${tableName}\`)`);
109
+ const cols = await connection.execute(sql, [], 'all', ctx);
110
+ const indexes = await connection.execute(`pragma index_list(\`${tableName}\`)`, [], 'all', ctx);
111
111
  const ret = [];
112
112
  for (const col of cols.filter(c => c.pk)) {
113
113
  ret.push({
@@ -119,7 +119,7 @@ class BaseSqliteSchemaHelper extends SchemaHelper_1.SchemaHelper {
119
119
  });
120
120
  }
121
121
  for (const index of indexes.filter(index => !this.isImplicitIndex(index.name))) {
122
- const res = await connection.execute(`pragma index_info(\`${index.name}\`)`);
122
+ const res = await connection.execute(`pragma index_info(\`${index.name}\`)`, [], 'all', ctx);
123
123
  ret.push(...res.map(row => ({
124
124
  columnNames: [row.name],
125
125
  keyName: index.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.6.11-dev.0",
3
+ "version": "6.6.11-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.10"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.6.11-dev.0",
69
+ "@mikro-orm/core": "6.6.11-dev.2",
70
70
  "better-sqlite3": "*",
71
71
  "libsql": "*",
72
72
  "mariadb": "*"
@@ -1,4 +1,4 @@
1
- import { type Configuration, type Dictionary, type EntityMetadata } from '@mikro-orm/core';
1
+ import { type Configuration, type Dictionary, type EntityMetadata, type Transaction } from '@mikro-orm/core';
2
2
  import { DatabaseTable } from './DatabaseTable';
3
3
  import type { AbstractSqlConnection } from '../AbstractSqlConnection';
4
4
  import type { AbstractSqlPlatform } from '../AbstractSqlPlatform';
@@ -34,7 +34,7 @@ export declare class DatabaseSchema {
34
34
  hasNamespace(namespace: string): boolean;
35
35
  hasNativeEnum(name: string): boolean;
36
36
  getNamespaces(): string[];
37
- static create(connection: AbstractSqlConnection, platform: AbstractSqlPlatform, config: Configuration, schemaName?: string, schemas?: string[], takeTables?: (string | RegExp)[], skipTables?: (string | RegExp)[]): Promise<DatabaseSchema>;
37
+ static create(connection: AbstractSqlConnection, platform: AbstractSqlPlatform, config: Configuration, schemaName?: string, schemas?: string[], takeTables?: (string | RegExp)[], skipTables?: (string | RegExp)[], ctx?: Transaction): Promise<DatabaseSchema>;
38
38
  static fromMetadata(metadata: EntityMetadata[], platform: AbstractSqlPlatform, config: Configuration, schemaName?: string): DatabaseSchema;
39
39
  private static getSchemaName;
40
40
  private static matchName;
@@ -59,14 +59,14 @@ class DatabaseSchema {
59
59
  getNamespaces() {
60
60
  return [...this.namespaces];
61
61
  }
62
- static async create(connection, platform, config, schemaName, schemas, takeTables, skipTables) {
62
+ static async create(connection, platform, config, schemaName, schemas, takeTables, skipTables, ctx) {
63
63
  const schema = new DatabaseSchema(platform, schemaName ?? config.get('schema') ?? platform.getDefaultSchemaName());
64
- const allTables = await connection.execute(platform.getSchemaHelper().getListTablesSQL());
64
+ const allTables = await connection.execute(platform.getSchemaHelper().getListTablesSQL(), [], 'all', ctx);
65
65
  const parts = config.get('migrations').tableName.split('.');
66
66
  const migrationsTableName = parts[1] ?? parts[0];
67
67
  const migrationsSchemaName = parts.length > 1 ? parts[0] : config.get('schema', platform.getDefaultSchemaName());
68
68
  const tables = allTables.filter(t => this.isTableNameAllowed(t.table_name, takeTables, skipTables) && (t.table_name !== migrationsTableName || (t.schema_name && t.schema_name !== migrationsSchemaName)));
69
- await platform.getSchemaHelper().loadInformationSchema(schema, connection, tables, schemas && schemas.length > 0 ? schemas : undefined);
69
+ await platform.getSchemaHelper().loadInformationSchema(schema, connection, tables, schemas && schemas.length > 0 ? schemas : undefined, ctx);
70
70
  return schema;
71
71
  }
72
72
  static fromMetadata(metadata, platform, config, schemaName) {
@@ -1,4 +1,4 @@
1
- import { type Connection, type Dictionary } from '@mikro-orm/core';
1
+ import { type Connection, type Dictionary, type Transaction } from '@mikro-orm/core';
2
2
  import type { Knex } from 'knex';
3
3
  import type { AbstractSqlConnection } from '../AbstractSqlConnection';
4
4
  import type { AbstractSqlPlatform } from '../AbstractSqlPlatform';
@@ -14,15 +14,15 @@ export declare abstract class SchemaHelper {
14
14
  getSchemaEnd(disableForeignKeys?: boolean): string;
15
15
  finalizeTable(table: Knex.TableBuilder, charset: string, collate?: string): void;
16
16
  supportsSchemaConstraints(): boolean;
17
- getPrimaryKeys(connection: AbstractSqlConnection, indexes: IndexDef[] | undefined, tableName: string, schemaName?: string): Promise<string[]>;
17
+ getPrimaryKeys(connection: AbstractSqlConnection, indexes: IndexDef[] | undefined, tableName: string, schemaName?: string, ctx?: Transaction): Promise<string[]>;
18
18
  inferLengthFromColumnType(type: string): number | undefined;
19
- getForeignKeys(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<Dictionary>;
19
+ getForeignKeys(connection: AbstractSqlConnection, tableName: string, schemaName?: string, ctx?: Transaction): Promise<Dictionary>;
20
20
  protected getTableKey(t: Table): string;
21
- getEnumDefinitions(connection: AbstractSqlConnection, checks: CheckDef[], tableName: string, schemaName?: string): Promise<Dictionary<string[]>>;
21
+ getEnumDefinitions(connection: AbstractSqlConnection, checks: CheckDef[], tableName: string, schemaName?: string, ctx?: Transaction): Promise<Dictionary<string[]>>;
22
22
  getCreateNativeEnumSQL(name: string, values: unknown[], schema?: string): string;
23
23
  getDropNativeEnumSQL(name: string, schema?: string): string;
24
24
  getAlterNativeEnumSQL(name: string, schema?: string, value?: string, items?: string[], oldItems?: string[]): string;
25
- loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[], schemas?: string[]): Promise<void>;
25
+ loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[], schemas?: string[], ctx?: Transaction): Promise<void>;
26
26
  getListTablesSQL(schemaName?: string): string;
27
27
  getRenameColumnSQL(tableName: string, oldColumnName: string, to: Column, schemaName?: string): string;
28
28
  getCreateIndexSQL(tableName: string, index: IndexDef, partialExpression?: boolean): string;
@@ -37,10 +37,10 @@ export declare abstract class SchemaHelper {
37
37
  getPostAlterTable(tableDiff: TableDifference, safe: boolean): string;
38
38
  getAlterColumnAutoincrement(tableName: string, column: Column, schemaName?: string): string;
39
39
  getChangeColumnCommentSQL(tableName: string, to: Column, schemaName?: string): string;
40
- getNamespaces(connection: AbstractSqlConnection): Promise<string[]>;
41
- getColumns(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<Column[]>;
42
- getIndexes(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<IndexDef[]>;
43
- getChecks(connection: AbstractSqlConnection, tableName: string, schemaName?: string, columns?: Column[]): Promise<CheckDef[]>;
40
+ getNamespaces(connection: AbstractSqlConnection, ctx?: Transaction): Promise<string[]>;
41
+ getColumns(connection: AbstractSqlConnection, tableName: string, schemaName?: string, ctx?: Transaction): Promise<Column[]>;
42
+ getIndexes(connection: AbstractSqlConnection, tableName: string, schemaName?: string, ctx?: Transaction): Promise<IndexDef[]>;
43
+ getChecks(connection: AbstractSqlConnection, tableName: string, schemaName?: string, columns?: Column[], ctx?: Transaction): Promise<CheckDef[]>;
44
44
  protected mapIndexes(indexes: IndexDef[]): Promise<IndexDef[]>;
45
45
  getForeignKeysSQL(tableName: string, schemaName?: string): string;
46
46
  mapForeignKeys(fks: any[], tableName: string, schemaName?: string): Dictionary;
@@ -31,7 +31,7 @@ class SchemaHelper {
31
31
  supportsSchemaConstraints() {
32
32
  return true;
33
33
  }
34
- async getPrimaryKeys(connection, indexes = [], tableName, schemaName) {
34
+ async getPrimaryKeys(connection, indexes = [], tableName, schemaName, ctx) {
35
35
  const pks = indexes.filter(i => i.primary).map(pk => pk.columnNames);
36
36
  return core_1.Utils.flatten(pks);
37
37
  }
@@ -42,8 +42,8 @@ class SchemaHelper {
42
42
  }
43
43
  return +match[1];
44
44
  }
45
- async getForeignKeys(connection, tableName, schemaName) {
46
- const fks = await connection.execute(this.getForeignKeysSQL(tableName, schemaName));
45
+ async getForeignKeys(connection, tableName, schemaName, ctx) {
46
+ const fks = await connection.execute(this.getForeignKeysSQL(tableName, schemaName), [], 'all', ctx);
47
47
  return this.mapForeignKeys(fks, tableName, schemaName);
48
48
  }
49
49
  getTableKey(t) {
@@ -57,7 +57,7 @@ class SchemaHelper {
57
57
  }
58
58
  return unquote(t.table_name);
59
59
  }
60
- async getEnumDefinitions(connection, checks, tableName, schemaName) {
60
+ async getEnumDefinitions(connection, checks, tableName, schemaName, ctx) {
61
61
  return {};
62
62
  }
63
63
  getCreateNativeEnumSQL(name, values, schema) {
@@ -69,15 +69,15 @@ class SchemaHelper {
69
69
  getAlterNativeEnumSQL(name, schema, value, items, oldItems) {
70
70
  throw new Error('Not supported by given driver');
71
71
  }
72
- async loadInformationSchema(schema, connection, tables, schemas) {
72
+ async loadInformationSchema(schema, connection, tables, schemas, ctx) {
73
73
  for (const t of tables) {
74
74
  const table = schema.addTable(t.table_name, t.schema_name, t.table_comment);
75
- const cols = await this.getColumns(connection, table.name, table.schema);
76
- const indexes = await this.getIndexes(connection, table.name, table.schema);
77
- const checks = await this.getChecks(connection, table.name, table.schema, cols);
78
- const pks = await this.getPrimaryKeys(connection, indexes, table.name, table.schema);
79
- const fks = await this.getForeignKeys(connection, table.name, table.schema);
80
- const enums = await this.getEnumDefinitions(connection, checks, table.name, table.schema);
75
+ const cols = await this.getColumns(connection, table.name, table.schema, ctx);
76
+ const indexes = await this.getIndexes(connection, table.name, table.schema, ctx);
77
+ const checks = await this.getChecks(connection, table.name, table.schema, cols, ctx);
78
+ const pks = await this.getPrimaryKeys(connection, indexes, table.name, table.schema, ctx);
79
+ const fks = await this.getForeignKeys(connection, table.name, table.schema, ctx);
80
+ const enums = await this.getEnumDefinitions(connection, checks, table.name, table.schema, ctx);
81
81
  table.init(cols, indexes, checks, pks, fks, enums);
82
82
  }
83
83
  }
@@ -173,16 +173,16 @@ class SchemaHelper {
173
173
  getChangeColumnCommentSQL(tableName, to, schemaName) {
174
174
  return '';
175
175
  }
176
- async getNamespaces(connection) {
176
+ async getNamespaces(connection, ctx) {
177
177
  return [];
178
178
  }
179
- async getColumns(connection, tableName, schemaName) {
179
+ async getColumns(connection, tableName, schemaName, ctx) {
180
180
  throw new Error('Not supported by given driver');
181
181
  }
182
- async getIndexes(connection, tableName, schemaName) {
182
+ async getIndexes(connection, tableName, schemaName, ctx) {
183
183
  throw new Error('Not supported by given driver');
184
184
  }
185
- async getChecks(connection, tableName, schemaName, columns) {
185
+ async getChecks(connection, tableName, schemaName, columns, ctx) {
186
186
  throw new Error('Not supported by given driver');
187
187
  }
188
188
  async mapIndexes(indexes) {