@mikro-orm/oracledb 7.1.0-dev.21 → 7.1.0-dev.23

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.
@@ -21,6 +21,7 @@ export declare class OracleSchemaHelper extends SchemaHelper {
21
21
  private getEnumDefinitions;
22
22
  private getChecksSQL;
23
23
  getAllChecks(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>, ctx?: Transaction): Promise<Dictionary<CheckDef[]>>;
24
+ getDatabaseCollation(connection: AbstractSqlConnection, ctx?: Transaction): Promise<string | undefined>;
24
25
  loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[], schemas?: string[], ctx?: Transaction): Promise<void>;
25
26
  getPreAlterTable(tableDiff: TableDifference, safe: boolean): string[];
26
27
  getPostAlterTable(tableDiff: TableDifference, safe: boolean): string[];
@@ -127,7 +127,8 @@ export class OracleSchemaHelper extends SchemaHelper {
127
127
  atc.char_length as character_maximum_length,
128
128
  atc.data_length as data_length,
129
129
  atc.identity_column as is_identity,
130
- atc.column_id as ordinal_position
130
+ atc.column_id as ordinal_position,
131
+ atc.collation as collation_name
131
132
  from all_tab_cols atc
132
133
  left join all_col_comments acc on atc.owner = acc.owner and atc.table_name = acc.table_name and atc.column_name = acc.column_name
133
134
  where atc.hidden_column = 'NO'
@@ -183,6 +184,11 @@ export class OracleSchemaHelper extends SchemaHelper {
183
184
  precision: col.numeric_precision,
184
185
  scale: col.numeric_scale,
185
186
  comment: col.column_comment,
187
+ // `USING_NLS_COMP` is the Oracle sentinel for "inherit from the session NLS settings", so
188
+ // a column without an explicit `COLLATE` clause introspects as `USING_NLS_COMP` rather
189
+ // than NULL. Treat it as "no explicit collation" so the comparator doesn't flag every
190
+ // string column as changed when the database default is something else (e.g. `BINARY`).
191
+ collation: col.collation_name && col.collation_name !== 'USING_NLS_COMP' ? col.collation_name : undefined,
186
192
  generated,
187
193
  });
188
194
  }
@@ -358,6 +364,10 @@ export class OracleSchemaHelper extends SchemaHelper {
358
364
  }
359
365
  return ret;
360
366
  }
367
+ async getDatabaseCollation(connection, ctx) {
368
+ const [row] = await connection.execute(`select property_value as collation from database_properties where property_name = 'DEFAULT_COLLATION'`, [], 'all', ctx);
369
+ return row?.collation;
370
+ }
361
371
  async loadInformationSchema(schema, connection, tables, schemas, ctx) {
362
372
  if (tables.length === 0) {
363
373
  return;
@@ -367,9 +377,11 @@ export class OracleSchemaHelper extends SchemaHelper {
367
377
  const indexes = await this.getAllIndexes(connection, tablesBySchema, ctx);
368
378
  const checks = await this.getAllChecks(connection, tablesBySchema, ctx);
369
379
  const fks = await this.getAllForeignKeys(connection, tablesBySchema, ctx);
380
+ const dbCollation = await this.getDatabaseCollation(connection, ctx);
370
381
  for (const t of tables) {
371
382
  const key = this.getTableKey(t);
372
383
  const table = schema.addTable(t.table_name, t.schema_name, t.table_comment);
384
+ table.collation = dbCollation;
373
385
  const pks = await this.getPrimaryKeys(connection, indexes[key], table.name, table.schema);
374
386
  const enums = this.getEnumDefinitions(checks[key] ?? []);
375
387
  table.init(columns[key], indexes[key], checks[key], pks, fks[key], enums);
@@ -470,6 +482,7 @@ export class OracleSchemaHelper extends SchemaHelper {
470
482
  /* v8 ignore next: generated column branch */
471
483
  const columnType = column.generated ? `as ${column.generated}` : column.type;
472
484
  const col = [this.quote(column.name), columnType];
485
+ Utils.runIfNotEmpty(() => col.push(this.getCollateSQL(column.collation)), column.collation);
473
486
  Utils.runIfNotEmpty(() => col.push('generated by default as identity'), column.autoincrement);
474
487
  /* v8 ignore next 3: default value branch */
475
488
  const useDefault = changedProperties
@@ -493,8 +506,15 @@ export class OracleSchemaHelper extends SchemaHelper {
493
506
  const parts = [];
494
507
  const quotedTableName = table.getQuotedName();
495
508
  // Oracle uses MODIFY for column changes, and always requires the column type
496
- if (changedProperties.has('type') || changedProperties.has('nullable') || changedProperties.has('default')) {
509
+ if (changedProperties.has('type') ||
510
+ changedProperties.has('nullable') ||
511
+ changedProperties.has('default') ||
512
+ changedProperties.has('collation')) {
497
513
  const colParts = [this.quote(column.name), column.type];
514
+ // Oracle's MODIFY restates the column type, so re-emit COLLATE whenever the column has
515
+ // one — even if the trigger was a nullable/default change — so we can't accidentally
516
+ // drop the column collation by omitting it from the new type spec.
517
+ Utils.runIfNotEmpty(() => colParts.push(this.getCollateSQL(column.collation)), column.collation);
498
518
  if (changedProperties.has('default')) {
499
519
  if (column.default != null && column.default !== 'null') {
500
520
  colParts.push(`default ${column.default}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/oracledb",
3
- "version": "7.1.0-dev.21",
3
+ "version": "7.1.0-dev.23",
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.1.0-dev.21",
45
+ "@mikro-orm/sql": "7.1.0-dev.23",
46
46
  "kysely": "0.28.16",
47
47
  "oracledb": "6.10.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@mikro-orm/core": "^7.0.12"
50
+ "@mikro-orm/core": "^7.0.13"
51
51
  },
52
52
  "peerDependencies": {
53
- "@mikro-orm/core": "7.1.0-dev.21"
53
+ "@mikro-orm/core": "7.1.0-dev.23"
54
54
  },
55
55
  "engines": {
56
56
  "node": ">= 22.17.0"