@mikro-orm/oracledb 7.1.9-dev.9 → 7.1.9

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.
package/OracleDriver.d.ts CHANGED
@@ -10,6 +10,12 @@ export declare class OracleDriver extends AbstractSqlDriver<OracleConnection, Or
10
10
  createQueryBuilder<T extends AnyEntity<T>>(entityName: EntityName<T>, ctx?: Transaction, preferredConnectionType?: ConnectionType, convertCustomTypes?: boolean, loggerContext?: LoggingOptions, alias?: string, em?: SqlEntityManager): OracleQueryBuilder<T, any, any, any>;
11
11
  nativeInsertMany<T extends object>(entityName: EntityName<T>, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
12
12
  nativeUpdateMany<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T> & UpsertManyOptions<T>): Promise<QueryResult<T>>;
13
+ /**
14
+ * Resolves the runtime type of every column a property maps to, aligned with its `fieldNames`.
15
+ * A relation covers one column per target PK column, and a target PK can be a relation itself,
16
+ * so we recurse down to the scalar leaves - `prop.runtimeType` is `unknown` for relations.
17
+ */
18
+ private getOutBindTypes;
13
19
  /** @inheritDoc */
14
20
  getORMClass(): Constructor<OracleMikroORM>;
15
21
  }
package/OracleDriver.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isRaw, QueryFlag, Utils, } from '@mikro-orm/core';
1
+ import { isRaw, QueryFlag, ReferenceKind, Utils, } from '@mikro-orm/core';
2
2
  import { AbstractSqlDriver } from '@mikro-orm/sql';
3
3
  import { OracleConnection } from './OracleConnection.js';
4
4
  import { OracleMikroORM } from './OracleMikroORM.js';
@@ -32,7 +32,7 @@ export class OracleDriver extends AbstractSqlDriver {
32
32
  let pk;
33
33
  if (pks.length > 1) {
34
34
  // owner has composite pk
35
- pk = data.map(d => Utils.getPrimaryKeyCond(d, pks));
35
+ pk = data.map(d => Utils.getOrderedPrimaryKeys(d, meta));
36
36
  }
37
37
  else {
38
38
  res.row ??= {};
@@ -61,8 +61,12 @@ export class OracleDriver extends AbstractSqlDriver {
61
61
  meta.props.filter(prop => prop.generated || prop.version || prop.primary).forEach(prop => returning.add(prop.name));
62
62
  for (const propName of returning) {
63
63
  const prop = meta.properties[propName];
64
- into.push(`:out_${prop.fieldNames[0]}`);
65
- outBindingsMap[`out_${prop.fieldNames[0]}`] = prop.runtimeType;
64
+ // the parent builds the `returning` list from all field names, so every column needs its own OUT bind
65
+ const runtimeTypes = this.getOutBindTypes(prop);
66
+ prop.fieldNames.forEach((fieldName, idx) => {
67
+ into.push(`:out_${fieldName}`);
68
+ outBindingsMap[`out_${fieldName}`] = runtimeTypes[idx];
69
+ });
66
70
  }
67
71
  const outBindings = this.platform.createOutBindings(outBindingsMap);
68
72
  return super.nativeUpdateMany(entityName, where, data, options, (sql, params) => {
@@ -74,6 +78,19 @@ export class OracleDriver extends AbstractSqlDriver {
74
78
  return `${sql} into ${into.join(', ')}`;
75
79
  });
76
80
  }
81
+ /**
82
+ * Resolves the runtime type of every column a property maps to, aligned with its `fieldNames`.
83
+ * A relation covers one column per target PK column, and a target PK can be a relation itself,
84
+ * so we recurse down to the scalar leaves - `prop.runtimeType` is `unknown` for relations.
85
+ */
86
+ getOutBindTypes(prop) {
87
+ if (!prop.targetMeta || ![ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind)) {
88
+ return prop.fieldNames.map(() => prop.runtimeType);
89
+ }
90
+ const types = prop.referencedPKs.flatMap(pk => this.getOutBindTypes(prop.targetMeta.properties[pk]));
91
+ // `fieldNames` of a polymorphic relation start with the discriminator column
92
+ return prop.polymorphic ? ['string', ...types] : types;
93
+ }
77
94
  /** @inheritDoc */
78
95
  getORMClass() {
79
96
  return OracleMikroORM;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/oracledb",
3
- "version": "7.1.9-dev.9",
3
+ "version": "7.1.9",
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.9-dev.9",
45
+ "@mikro-orm/sql": "7.1.9",
46
46
  "kysely": "0.29.4",
47
47
  "oracledb": "7.0.1"
48
48
  },
49
49
  "devDependencies": {
50
- "@mikro-orm/core": "^7.1.8"
50
+ "@mikro-orm/core": "^7.1.9"
51
51
  },
52
52
  "peerDependencies": {
53
- "@mikro-orm/core": "7.1.9-dev.9"
53
+ "@mikro-orm/core": "7.1.9"
54
54
  },
55
55
  "engines": {
56
56
  "node": ">= 22.17.0"