@mikro-orm/oracledb 7.0.7-dev.2 → 7.0.7-dev.20

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,25 +1,25 @@
1
- import { type AbstractSqlConnection, type CheckDef, type Column, type DatabaseSchema, type DatabaseTable, type Dictionary, type ForeignKey, type IndexDef, SchemaHelper, type Table, type TableDifference, type Type } from '@mikro-orm/sql';
1
+ import { type AbstractSqlConnection, type CheckDef, type Column, type DatabaseSchema, type DatabaseTable, type Dictionary, type ForeignKey, type IndexDef, SchemaHelper, type Table, type TableDifference, type Transaction, type Type } from '@mikro-orm/sql';
2
2
  /** Schema introspection helper for Oracle Database. */
3
3
  export declare class OracleSchemaHelper extends SchemaHelper {
4
4
  static readonly DEFAULT_VALUES: Record<string, string[]>;
5
5
  getDatabaseExistsSQL(name: string): string;
6
- getAllTables(connection: AbstractSqlConnection, schemas?: string[]): Promise<Table[]>;
6
+ getAllTables(connection: AbstractSqlConnection, schemas?: string[], ctx?: Transaction): Promise<Table[]>;
7
7
  getListTablesSQL(schemaName?: string): string;
8
8
  getListViewsSQL(): string;
9
- loadViews(schema: DatabaseSchema, connection: AbstractSqlConnection): Promise<void>;
10
- getNamespaces(connection: AbstractSqlConnection): Promise<string[]>;
9
+ loadViews(schema: DatabaseSchema, connection: AbstractSqlConnection, schemaName?: string, ctx?: Transaction): Promise<void>;
10
+ getNamespaces(connection: AbstractSqlConnection, ctx?: Transaction): Promise<string[]>;
11
11
  private getIgnoredNamespacesConditionSQL;
12
12
  getDefaultEmptyString(): string;
13
13
  normalizeDefaultValue(defaultValue: string, length: number, defaultValues?: Dictionary<string[]>, stripQuotes?: boolean): string | number;
14
- getAllColumns(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>): Promise<Dictionary<Column[]>>;
15
- getAllIndexes(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>): Promise<Dictionary<IndexDef[]>>;
14
+ getAllColumns(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>, ctx?: Transaction): Promise<Dictionary<Column[]>>;
15
+ getAllIndexes(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>, ctx?: Transaction): Promise<Dictionary<IndexDef[]>>;
16
16
  mapForeignKeys(fks: any[], tableName: string, schemaName?: string): Dictionary;
17
17
  createForeignKey(table: DatabaseTable, foreignKey: ForeignKey, alterTable?: boolean, inline?: boolean): string;
18
- getAllForeignKeys(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>): Promise<Dictionary<Dictionary<ForeignKey>>>;
18
+ getAllForeignKeys(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>, ctx?: Transaction): Promise<Dictionary<Dictionary<ForeignKey>>>;
19
19
  private getEnumDefinitions;
20
20
  private getChecksSQL;
21
- getAllChecks(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>): Promise<Dictionary<CheckDef[]>>;
22
- loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[]): Promise<void>;
21
+ getAllChecks(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>, ctx?: Transaction): Promise<Dictionary<CheckDef[]>>;
22
+ loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[], schemas?: string[], ctx?: Transaction): Promise<void>;
23
23
  getPreAlterTable(tableDiff: TableDifference, safe: boolean): string[];
24
24
  getPostAlterTable(tableDiff: TableDifference, safe: boolean): string[];
25
25
  getCreateNamespaceSQL(name: string): string;
@@ -10,9 +10,9 @@ export class OracleSchemaHelper extends SchemaHelper {
10
10
  getDatabaseExistsSQL(name) {
11
11
  return `select 1 from all_users where username = ${this.platform.quoteValue(name)}`;
12
12
  }
13
- async getAllTables(connection, schemas) {
13
+ async getAllTables(connection, schemas, ctx) {
14
14
  if (!schemas || schemas.length === 0) {
15
- return connection.execute(this.getListTablesSQL());
15
+ return connection.execute(this.getListTablesSQL(), [], 'all', ctx);
16
16
  }
17
17
  const conditions = schemas.map(s => `at.owner = ${this.platform.quoteValue(s)}`).join(' or ');
18
18
  const sql = `select at.table_name, at.owner as schema_name, atc.comments as table_comment
@@ -20,7 +20,7 @@ export class OracleSchemaHelper extends SchemaHelper {
20
20
  left join all_tab_comments atc on at.owner = atc.owner and at.table_name = atc.table_name
21
21
  where (${conditions})
22
22
  order by schema_name, at.table_name`;
23
- return connection.execute(sql);
23
+ return connection.execute(sql, [], 'all', ctx);
24
24
  }
25
25
  getListTablesSQL(schemaName) {
26
26
  /* v8 ignore next: nullish coalescing chain */
@@ -47,8 +47,8 @@ export class OracleSchemaHelper extends SchemaHelper {
47
47
  where owner = ${this.platform.quoteValue(schema)}
48
48
  order by view_name`;
49
49
  }
50
- async loadViews(schema, connection) {
51
- const views = await connection.execute(this.getListViewsSQL());
50
+ async loadViews(schema, connection, schemaName, ctx) {
51
+ const views = await connection.execute(this.getListViewsSQL(), [], 'all', ctx);
52
52
  for (const view of views) {
53
53
  const definition = view.view_definition?.trim();
54
54
  /* v8 ignore next 4: empty view definition edge case */
@@ -58,9 +58,9 @@ export class OracleSchemaHelper extends SchemaHelper {
58
58
  }
59
59
  }
60
60
  }
61
- async getNamespaces(connection) {
61
+ async getNamespaces(connection, ctx) {
62
62
  const sql = `select username as schema_name from all_users where ${this.getIgnoredNamespacesConditionSQL()} order by username`;
63
- const res = await connection.execute(sql);
63
+ const res = await connection.execute(sql, [], 'all', ctx);
64
64
  return res.map(row => row.schema_name);
65
65
  }
66
66
  getIgnoredNamespacesConditionSQL(column = 'username') {
@@ -104,7 +104,7 @@ export class OracleSchemaHelper extends SchemaHelper {
104
104
  }
105
105
  return super.normalizeDefaultValue(defaultValue, length, OracleSchemaHelper.DEFAULT_VALUES);
106
106
  }
107
- async getAllColumns(connection, tablesBySchemas) {
107
+ async getAllColumns(connection, tablesBySchemas, ctx) {
108
108
  const sql = `select
109
109
  atc.owner as schema_name,
110
110
  atc.table_name as table_name,
@@ -127,7 +127,7 @@ export class OracleSchemaHelper extends SchemaHelper {
127
127
  where atc.hidden_column = 'NO'
128
128
  and (${[...tablesBySchemas.entries()].map(([schema, tables]) => `(atc.table_name in (${tables.map(t => this.platform.quoteValue(t.table_name)).join(', ')}) and atc.owner = ${this.platform.quoteValue(schema)})`).join(' or ')})
129
129
  order by atc.owner, atc.table_name, atc.column_id`;
130
- const allColumns = await connection.execute(sql);
130
+ const allColumns = await connection.execute(sql, [], 'all', ctx);
131
131
  const str = (val) => (val != null ? '' + val : val);
132
132
  const ret = {};
133
133
  for (const col of allColumns) {
@@ -182,7 +182,7 @@ export class OracleSchemaHelper extends SchemaHelper {
182
182
  }
183
183
  return ret;
184
184
  }
185
- async getAllIndexes(connection, tablesBySchemas) {
185
+ async getAllIndexes(connection, tablesBySchemas, ctx) {
186
186
  // Query indexes and join with constraints to identify which indexes back PRIMARY KEY or UNIQUE constraints
187
187
  // Also join with all_ind_expressions to get function-based index expressions
188
188
  const sql = `select ind.table_owner as schema_name, ind.table_name, ind.index_name, aic.column_name,
@@ -197,7 +197,7 @@ export class OracleSchemaHelper extends SchemaHelper {
197
197
  left join all_ind_expressions aie on ind.owner = aie.index_owner and ind.index_name = aie.index_name and aic.column_position = aie.column_position
198
198
  where (${[...tablesBySchemas.entries()].map(([schema, tables]) => `(ind.table_name in (${tables.map(t => this.platform.quoteValue(t.table_name)).join(', ')}) and ind.table_owner = ${this.platform.quoteValue(schema)})`).join(' or ')})
199
199
  order by ind.table_name, ind.index_name, aic.column_position`;
200
- const allIndexes = await connection.execute(sql);
200
+ const allIndexes = await connection.execute(sql, [], 'all', ctx);
201
201
  const ret = {};
202
202
  for (const index of allIndexes) {
203
203
  const key = this.getTableKey(index);
@@ -251,7 +251,7 @@ export class OracleSchemaHelper extends SchemaHelper {
251
251
  deleteRule: supportedDeleteRules.includes(foreignKey.deleteRule ?? '') ? foreignKey.deleteRule : undefined,
252
252
  }, alterTable, inline);
253
253
  }
254
- async getAllForeignKeys(connection, tablesBySchemas) {
254
+ async getAllForeignKeys(connection, tablesBySchemas, ctx) {
255
255
  const sql = `select fk_cons.constraint_name, fk_cons.table_name, fk_cons.owner as schema_name, fk_cols.column_name,
256
256
  fk_cons.r_owner as referenced_schema_name,
257
257
  pk_cols.column_name as referenced_column_name,
@@ -265,7 +265,7 @@ export class OracleSchemaHelper extends SchemaHelper {
265
265
  where fk_cons.constraint_type = 'R'
266
266
  and (${[...tablesBySchemas.entries()].map(([schema, tables]) => `(fk_cons.table_name in (${tables.map(t => this.platform.quoteValue(t.table_name)).join(', ')}) and fk_cons.owner = ${this.platform.quoteValue(schema)})`).join(' or ')})
267
267
  order by fk_cons.owner, fk_cons.table_name, fk_cons.constraint_name, pk_cols.position`;
268
- const allFks = await connection.execute(sql);
268
+ const allFks = await connection.execute(sql, [], 'all', ctx);
269
269
  const ret = {};
270
270
  for (const fk of allFks) {
271
271
  // Oracle returns schema names in uppercase - normalize to lowercase for consistency
@@ -321,9 +321,9 @@ export class OracleSchemaHelper extends SchemaHelper {
321
321
  and (${[...tablesBySchemas.entries()].map(([schema, tables]) => `(con.table_name in (${tables.map(t => this.platform.quoteValue(t.table_name)).join(', ')}) and con.owner = ${this.platform.quoteValue(schema)})`).join(' or ')})
322
322
  order by con.constraint_name`;
323
323
  }
324
- async getAllChecks(connection, tablesBySchemas) {
324
+ async getAllChecks(connection, tablesBySchemas, ctx) {
325
325
  const sql = this.getChecksSQL(tablesBySchemas);
326
- const allChecks = await connection.execute(sql);
326
+ const allChecks = await connection.execute(sql, [], 'all', ctx);
327
327
  const ret = {};
328
328
  for (const check of allChecks) {
329
329
  const key = this.getTableKey(check);
@@ -338,15 +338,15 @@ export class OracleSchemaHelper extends SchemaHelper {
338
338
  }
339
339
  return ret;
340
340
  }
341
- async loadInformationSchema(schema, connection, tables) {
341
+ async loadInformationSchema(schema, connection, tables, schemas, ctx) {
342
342
  if (tables.length === 0) {
343
343
  return;
344
344
  }
345
345
  const tablesBySchema = this.getTablesGroupedBySchemas(tables);
346
- const columns = await this.getAllColumns(connection, tablesBySchema);
347
- const indexes = await this.getAllIndexes(connection, tablesBySchema);
348
- const checks = await this.getAllChecks(connection, tablesBySchema);
349
- const fks = await this.getAllForeignKeys(connection, tablesBySchema);
346
+ const columns = await this.getAllColumns(connection, tablesBySchema, ctx);
347
+ const indexes = await this.getAllIndexes(connection, tablesBySchema, ctx);
348
+ const checks = await this.getAllChecks(connection, tablesBySchema, ctx);
349
+ const fks = await this.getAllForeignKeys(connection, tablesBySchema, ctx);
350
350
  for (const t of tables) {
351
351
  const key = this.getTableKey(t);
352
352
  const table = schema.addTable(t.table_name, t.schema_name, t.table_comment);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/oracledb",
3
- "version": "7.0.7-dev.2",
3
+ "version": "7.0.7-dev.20",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL, SQLite, MSSQL and Oracle databases.",
5
5
  "keywords": [
6
6
  "data-mapper",
@@ -42,15 +42,15 @@
42
42
  "copy": "node ../../scripts/copy.mjs"
43
43
  },
44
44
  "dependencies": {
45
- "@mikro-orm/sql": "7.0.7-dev.2",
46
- "kysely": "0.28.14",
45
+ "@mikro-orm/sql": "7.0.7-dev.20",
46
+ "kysely": "0.28.15",
47
47
  "oracledb": "6.10.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@mikro-orm/core": "^7.0.6"
51
51
  },
52
52
  "peerDependencies": {
53
- "@mikro-orm/core": "7.0.7-dev.2"
53
+ "@mikro-orm/core": "7.0.7-dev.20"
54
54
  },
55
55
  "engines": {
56
56
  "node": ">= 22.17.0"