@mikro-orm/oracledb 7.0.0-dev.316

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Martin Adámek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,11 @@
1
+ import { AbstractSqlConnection, type AnyEntity, type EntityData, type LoggingOptions, NativeQueryBuilder, OracleDialect, type QueryResult, RawQueryFragment, type Transaction } from '@mikro-orm/sql';
2
+ import { type PoolAttributes } from 'oracledb';
3
+ export declare class OracleConnection extends AbstractSqlConnection {
4
+ createKyselyDialect(overrides: PoolAttributes): Promise<OracleDialect>;
5
+ mapOptions(overrides: PoolAttributes): PoolAttributes;
6
+ execute<T extends QueryResult | EntityData<AnyEntity> | EntityData<AnyEntity>[] = EntityData<AnyEntity>[]>(query: string | NativeQueryBuilder | RawQueryFragment, params?: readonly unknown[], method?: 'all' | 'get' | 'run', ctx?: Transaction, loggerContext?: LoggingOptions): Promise<T>;
7
+ /** @inheritDoc */
8
+ executeDump(dump: string): Promise<void>;
9
+ private stripTrailingSemicolon;
10
+ protected transformRawResult<T>(res: any, method: 'all' | 'get' | 'run'): T;
11
+ }
@@ -0,0 +1,176 @@
1
+ import { AbstractSqlConnection, NativeQueryBuilder, OracleDialect, RawQueryFragment, Utils, } from '@mikro-orm/sql';
2
+ import { CompiledQuery } from 'kysely';
3
+ import oracledb from 'oracledb';
4
+ export class OracleConnection extends AbstractSqlConnection {
5
+ async createKyselyDialect(overrides) {
6
+ const options = this.mapOptions(overrides);
7
+ const password = options.password;
8
+ const onCreateConnection = this.options.onCreateConnection ?? this.config.get('onCreateConnection');
9
+ const poolOptions = {
10
+ ...options,
11
+ /* v8 ignore next: password-as-function branch requires mocking pool creation */
12
+ password: typeof password === 'function' ? await password() : password,
13
+ sessionCallback: onCreateConnection,
14
+ };
15
+ // Retry pool creation for transient Oracle errors (e.g. ORA-01017 under load)
16
+ let pool;
17
+ const maxRetries = 3;
18
+ for (let attempt = 1;; attempt++) {
19
+ try {
20
+ pool = await oracledb.createPool(poolOptions);
21
+ break;
22
+ /* v8 ignore start: transient Oracle pool-creation errors are not reproducible in tests */
23
+ }
24
+ catch (e) {
25
+ if (attempt < maxRetries && (e.errorNum === 1017 || e.errorNum === 12514 || e.errorNum === 12541)) {
26
+ await new Promise(resolve => setTimeout(resolve, 250 * attempt));
27
+ continue;
28
+ }
29
+ throw e;
30
+ }
31
+ /* v8 ignore stop */
32
+ }
33
+ const executeOptions = {
34
+ fetchTypeHandler: metaData => {
35
+ const bigInt = metaData.dbType === oracledb.DB_TYPE_NUMBER && (metaData.precision ?? 0) > 10;
36
+ metaData.name = metaData.name.toLowerCase();
37
+ if (bigInt || metaData.dbType === oracledb.DB_TYPE_CLOB) {
38
+ return {
39
+ type: oracledb.DB_TYPE_VARCHAR,
40
+ };
41
+ }
42
+ if (metaData.dbType === oracledb.DB_TYPE_BLOB) {
43
+ return {
44
+ type: oracledb.BUFFER,
45
+ };
46
+ }
47
+ return undefined;
48
+ },
49
+ };
50
+ return new OracleDialect({
51
+ pool,
52
+ executeOptions: executeOptions,
53
+ });
54
+ }
55
+ mapOptions(overrides) {
56
+ const ret = { ...this.getConnectionOptions() };
57
+ const dbName = this.config.get('dbName');
58
+ const pool = this.config.get('pool');
59
+ ret.poolMin = pool?.min;
60
+ ret.poolMax = pool?.max;
61
+ ret.poolTimeout = pool?.idleTimeoutMillis;
62
+ const user = this.config.get('user', dbName);
63
+ ret.user = user.startsWith('"') || user === 'system' ? user : this.platform.quoteIdentifier(user);
64
+ ret.connectionString = this.options.clientUrl ?? this.platform.getDefaultClientUrl();
65
+ Reflect.deleteProperty(ret, 'database');
66
+ Reflect.deleteProperty(ret, 'port');
67
+ Reflect.deleteProperty(ret, 'host');
68
+ return Utils.mergeConfig(ret, overrides);
69
+ }
70
+ async execute(query, params = [], method = 'all', ctx, loggerContext) {
71
+ await this.ensureConnection();
72
+ if (query instanceof NativeQueryBuilder) {
73
+ query = query.toRaw();
74
+ }
75
+ if (query instanceof RawQueryFragment) {
76
+ params = query.params;
77
+ query = query.sql;
78
+ }
79
+ query = this.stripTrailingSemicolon(query);
80
+ let last;
81
+ let rawQuery;
82
+ const lastParam = params[params.length - 1];
83
+ if (Utils.isObject(lastParam) && '__outBindings' in lastParam && lastParam.__outBindings) {
84
+ rawQuery = lastParam.__rawQuery;
85
+ const { __outBindings, ...rest } = lastParam;
86
+ last = rest;
87
+ params = [...params.slice(0, -1), last];
88
+ }
89
+ query = this.config.get('onQuery')(query, params);
90
+ const formatted = this.platform.formatQuery(query, params);
91
+ const sql = this.getSql(rawQuery ?? query, formatted, loggerContext);
92
+ return this.executeQuery(sql, async () => {
93
+ const compiled = CompiledQuery.raw(formatted, last);
94
+ if (ctx) {
95
+ const res = await ctx.executeQuery(compiled);
96
+ return this.transformRawResult(res, method);
97
+ }
98
+ const res = await this.getClient().executeQuery({
99
+ ...compiled,
100
+ autoCommit: true,
101
+ });
102
+ return this.transformRawResult(res, method);
103
+ }, { query, params, ...loggerContext });
104
+ }
105
+ /** @inheritDoc */
106
+ async executeDump(dump) {
107
+ await this.ensureConnection();
108
+ const lines = dump.split('\n').filter(i => i.trim());
109
+ for (let line of lines) {
110
+ if (line.startsWith('--')) {
111
+ continue;
112
+ }
113
+ line = this.stripTrailingSemicolon(line);
114
+ const raw = CompiledQuery.raw(line);
115
+ const now = Date.now();
116
+ try {
117
+ await this.getClient().executeQuery(raw);
118
+ }
119
+ catch (e) {
120
+ this.logQuery(line, { took: Date.now() - now, level: 'error', query: line });
121
+ throw e;
122
+ }
123
+ }
124
+ }
125
+ stripTrailingSemicolon(sql) {
126
+ if (sql.endsWith(';') && !/end(\s+\w+)?;$/i.test(sql)) {
127
+ return sql.slice(0, -1);
128
+ }
129
+ return sql;
130
+ }
131
+ transformRawResult(res, method) {
132
+ if (method === 'get') {
133
+ return res.rows[0];
134
+ }
135
+ if (method === 'all') {
136
+ return res.rows;
137
+ }
138
+ if (res.numAffectedRows > 0n && res.outBinds) {
139
+ const keys = Object.keys(res.outBinds);
140
+ const rows = [];
141
+ res.rows = rows;
142
+ for (let i = 0; i < res.numAffectedRows; i++) {
143
+ const o = {};
144
+ for (const key of keys) {
145
+ o[key.replace(/^out_/, '')] = res.outBinds[key][i];
146
+ }
147
+ rows.push(o);
148
+ }
149
+ }
150
+ else if (res.outBinds) {
151
+ const keys = Object.keys(res.outBinds);
152
+ const rows = [];
153
+ for (const key of keys) {
154
+ const [k, i] = key.split('__');
155
+ rows[+i] ??= {};
156
+ rows[+i][k.replace(/^out_/, '')] = res.outBinds[key];
157
+ }
158
+ res.rows = rows;
159
+ }
160
+ const rowCount = res.rows.length;
161
+ /* v8 ignore start: internal result-shape branches depend on Oracle driver internals */
162
+ const hasEmptyCount = rowCount === 1 && '' in res.rows[0];
163
+ const emptyRow = hasEmptyCount && Number(res.rows[0]['']);
164
+ const affectedRows = hasEmptyCount
165
+ ? emptyRow
166
+ : res.numAffectedRows == null
167
+ ? rowCount
168
+ : Number(res.numAffectedRows ?? rowCount);
169
+ /* v8 ignore stop */
170
+ return {
171
+ affectedRows,
172
+ row: res.rows[0],
173
+ rows: res.rows,
174
+ };
175
+ }
176
+ }
@@ -0,0 +1,14 @@
1
+ import { type AnyEntity, type Configuration, type ConnectionType, type Constructor, type EntityDictionary, type EntityName, type FilterQuery, type LoggingOptions, type NativeInsertUpdateManyOptions, type QueryResult, type Transaction, type UpsertManyOptions } from '@mikro-orm/core';
2
+ import { AbstractSqlDriver, type SqlEntityManager } from '@mikro-orm/sql';
3
+ import { OracleConnection } from './OracleConnection.js';
4
+ import { OracleMikroORM } from './OracleMikroORM.js';
5
+ import { OracleQueryBuilder } from './OracleQueryBuilder.js';
6
+ import { OraclePlatform } from './OraclePlatform.js';
7
+ export declare class OracleDriver extends AbstractSqlDriver<OracleConnection, OraclePlatform> {
8
+ constructor(config: Configuration);
9
+ 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>;
10
+ nativeInsertMany<T extends object>(entityName: EntityName<T>, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
11
+ nativeUpdateMany<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T> & UpsertManyOptions<T>): Promise<QueryResult<T>>;
12
+ /** @inheritDoc */
13
+ getORMClass(): Constructor<OracleMikroORM>;
14
+ }
@@ -0,0 +1,80 @@
1
+ import { isRaw, QueryFlag, Utils, } from '@mikro-orm/core';
2
+ import { AbstractSqlDriver } from '@mikro-orm/sql';
3
+ import { OracleConnection } from './OracleConnection.js';
4
+ import { OracleMikroORM } from './OracleMikroORM.js';
5
+ import { OracleQueryBuilder } from './OracleQueryBuilder.js';
6
+ import { OraclePlatform } from './OraclePlatform.js';
7
+ export class OracleDriver extends AbstractSqlDriver {
8
+ constructor(config) {
9
+ super(config, new OraclePlatform(), OracleConnection, ['kysely', 'oracledb']);
10
+ }
11
+ createQueryBuilder(entityName, ctx, preferredConnectionType, convertCustomTypes, loggerContext, alias, em) {
12
+ // do not compute the connectionType if EM is provided as it will be computed from it in the QB later on
13
+ const connectionType = em
14
+ ? preferredConnectionType
15
+ : this.resolveConnectionType({ ctx, connectionType: preferredConnectionType });
16
+ const qb = new OracleQueryBuilder(entityName, this.metadata, this, ctx, alias, connectionType, em, loggerContext);
17
+ if (!convertCustomTypes) {
18
+ qb.unsetFlag(QueryFlag.CONVERT_CUSTOM_TYPES);
19
+ }
20
+ return qb;
21
+ }
22
+ async nativeInsertMany(entityName, data, options = {}) {
23
+ options.processCollections ??= true;
24
+ options.convertCustomTypes ??= true;
25
+ const meta = this.metadata.get(entityName);
26
+ const pks = this.getPrimaryKeyFields(meta);
27
+ const collections = options.processCollections ? data.map(d => this.extractManyToMany(meta, d)) : [];
28
+ const qb = this.createQueryBuilder(entityName, options.ctx, 'write', options.convertCustomTypes).withSchema(this.getSchemaName(meta, options));
29
+ qb.insert(data);
30
+ const res = await this.rethrow(qb.execute('run'));
31
+ let pk;
32
+ if (pks.length > 1) {
33
+ // owner has composite pk
34
+ pk = data.map(d => Utils.getPrimaryKeyCond(d, pks));
35
+ }
36
+ else {
37
+ res.row ??= {};
38
+ res.rows ??= [];
39
+ pk = data.map((d, i) => d[pks[0]] ?? res.rows[i]?.[pks[0]]).map(d => [d]);
40
+ res.insertId = res.insertId || res.row[pks[0]];
41
+ }
42
+ for (let i = 0; i < collections.length; i++) {
43
+ await this.processManyToMany(meta, pk[i], collections[i], false, options);
44
+ }
45
+ return res;
46
+ }
47
+ async nativeUpdateMany(entityName, where, data, options = {}) {
48
+ const meta = this.metadata.get(entityName);
49
+ const returning = new Set();
50
+ const into = [];
51
+ const outBindingsMap = {};
52
+ for (const row of data) {
53
+ for (const k of Utils.keys(row)) {
54
+ if (isRaw(row[k])) {
55
+ returning.add(k);
56
+ }
57
+ }
58
+ }
59
+ // reload generated columns and version fields
60
+ meta.props.filter(prop => prop.generated || prop.version || prop.primary).forEach(prop => returning.add(prop.name));
61
+ for (const propName of returning) {
62
+ const prop = meta.properties[propName];
63
+ into.push(`:out_${prop.fieldNames[0]}`);
64
+ outBindingsMap[`out_${prop.fieldNames[0]}`] = prop.runtimeType;
65
+ }
66
+ const outBindings = this.platform.createOutBindings(outBindingsMap);
67
+ return super.nativeUpdateMany(entityName, where, data, options, (sql, params) => {
68
+ /* v8 ignore next 2: defensive guard — PKs are always added to `returning` above */
69
+ if (into.length === 0) {
70
+ return sql;
71
+ }
72
+ params.push(outBindings);
73
+ return `${sql} into ${into.join(', ')}`;
74
+ });
75
+ }
76
+ /** @inheritDoc */
77
+ getORMClass() {
78
+ return OracleMikroORM;
79
+ }
80
+ }
@@ -0,0 +1,7 @@
1
+ import { ExceptionConverter, type Dictionary, type DriverException } from '@mikro-orm/core';
2
+ export declare class OracleExceptionConverter extends ExceptionConverter {
3
+ /**
4
+ * @link https://docs.oracle.com/cd/B28359_01/server.111/b28278/toc.htm
5
+ */
6
+ convertException(exception: Error & Dictionary): DriverException;
7
+ }
@@ -0,0 +1,145 @@
1
+ import { CheckConstraintViolationException, ExceptionConverter, InvalidFieldNameException, NonUniqueFieldNameException, NotNullConstraintViolationException, SyntaxErrorException, TableExistsException, TableNotFoundException, UniqueConstraintViolationException, DatabaseObjectNotFoundException, ForeignKeyConstraintViolationException, ReadOnlyException, ConnectionException, DeadlockException, LockWaitTimeoutException, } from '@mikro-orm/core';
2
+ /* v8 ignore start */
3
+ export class OracleExceptionConverter extends ExceptionConverter {
4
+ /**
5
+ * @link https://docs.oracle.com/cd/B28359_01/server.111/b28278/toc.htm
6
+ */
7
+ convertException(exception) {
8
+ switch (exception.errorNum) {
9
+ case 1: // ORA-00001: unique constraint (string.string) violated
10
+ return new UniqueConstraintViolationException(exception);
11
+ case 54: // ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
12
+ return new LockWaitTimeoutException(exception);
13
+ case 18: // ORA-00018: maximum number of sessions exceeded
14
+ case 19: // ORA-00019: maximum number of session licenses exceeded
15
+ case 20: // ORA-00020: maximum number of processes (string) exceeded
16
+ case 22: // ORA-00022: invalid session ID; access denied
17
+ case 107: // ORA-00107: failed to connect to ORACLE listener process
18
+ case 1017: // ORA-01017: invalid username/password; logon denied
19
+ case 2010: // ORA-02010: missing host connect string
20
+ case 3113: // ORA-03113: end-of-file on communication channel
21
+ case 3135: // ORA-03135: connection lost contact
22
+ case 12154: // ORA-12154: TNS:could not resolve service name
23
+ case 12198: // ORA-12198: TNS:could not find path to destination
24
+ case 12203: // ORA-12203: TNS:unable to connect to destination
25
+ case 12500: // ORA-12500: TNS:listener failed to start a dedicated server process
26
+ case 12504: // ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
27
+ case 12505: // ORA-12505: TNS:listener does not currently know of SID given in connect descriptor
28
+ case 12511: // ORA-12511: TNS:service handler found but it is not accepting connections
29
+ case 12513: // ORA-12513: TNS:service handler found but it has registered for a different protocol
30
+ case 12514: // ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
31
+ case 12533: // ORA-12533: TNS:illegal ADDRESS parameters
32
+ case 12545: // ORA-12545: TNS:name lookup failure
33
+ case 12560: // ORA-12560: TNS:protocol adapter error
34
+ case 12537: // ORA-12537: TNS:connection closed
35
+ return new ConnectionException(exception);
36
+ case 28: // ORA-00028: your session has been killed
37
+ return new ConnectionException(exception);
38
+ case 60: // ORA-00060: deadlock detected while waiting for resource
39
+ return new DeadlockException(exception);
40
+ case 904: // ORA-00904: invalid column name
41
+ return new InvalidFieldNameException(exception);
42
+ case 918: // ORA-00918: column ambiguously defined
43
+ case 957: // ORA-00957: duplicate column name
44
+ case 960: // ORA-00960: ambiguous column naming in select list
45
+ return new NonUniqueFieldNameException(exception);
46
+ case 900: // ORA-00900: invalid SQL statement
47
+ case 901: // ORA-00901: invalid CREATE command
48
+ case 902: // ORA-00902: invalid datatype
49
+ case 905: // ORA-00905: missing keyword
50
+ case 906: // ORA-00906: missing left parenthesis
51
+ case 907: // ORA-00907: missing right parenthesis
52
+ case 908: // ORA-00908: missing NULL keyword
53
+ case 909: // ORA-00909: invalid number of arguments
54
+ case 910: // ORA-00910: specified length too long for its datatype
55
+ case 911: // ORA-00911: invalid character
56
+ case 912: // ORA-00912: input parameter too long
57
+ case 913: // ORA-00913: too many values
58
+ case 914: // ORA-00914: missing ADD keyword
59
+ case 917: // ORA-00917: missing comma
60
+ case 919: // ORA-00919: invalid function
61
+ case 920: // ORA-00920: invalid relational operator
62
+ case 921: // ORA-00921: unexpected end of SQL command
63
+ case 922: // ORA-00922: missing or invalid option
64
+ case 923: // ORA-00923: FROM keyword not found where expected
65
+ case 924: // ORA-00924: missing BY keyword
66
+ case 925: // ORA-00925: missing INTO keyword
67
+ case 926: // ORA-00926: missing VALUES keyword
68
+ case 927: // ORA-00927: missing equal sign
69
+ case 928: // ORA-00928: missing SELECT keyword
70
+ case 929: // ORA-00929: missing period
71
+ case 930: // ORA-00930: missing asterisk
72
+ case 931: // ORA-00931: missing identifier
73
+ case 932: // ORA-00932: inconsistent datatypes
74
+ case 933: // ORA-00933: SQL command not properly ended
75
+ case 934: // ORA-00934: group function is not allowed here
76
+ case 935: // ORA-00935: group function is nested too deeply
77
+ case 936: // ORA-00936: missing expression
78
+ case 937: // ORA-00937: not a single-group group function
79
+ case 938: // ORA-00938: not enough arguments for function
80
+ case 939: // ORA-00939: too many arguments for function
81
+ case 940: // ORA-00940: invalid ALTER command
82
+ case 941: // ORA-00941: missing cluster name
83
+ case 946: // ORA-00946: missing TO keyword
84
+ case 947: // ORA-00947: not enough values
85
+ case 950: // ORA-00950: invalid DROP option
86
+ case 952: // ORA-00952: missing GROUP keyword
87
+ case 954: // ORA-00954: missing IDENTIFIED keyword
88
+ case 956: // ORA-00956: missing or invalid auditing option
89
+ case 962: // ORA-00962: too many group-by or order-by expressions
90
+ case 964: // ORA-00964: table name not in FROM list
91
+ case 965: // ORA-00965: column aliases not allowed for "*"
92
+ case 966: // ORA-00966: missing TABLE keyword
93
+ case 967: // ORA-00967: missing WHERE keyword
94
+ case 968: // ORA-00968: missing INDEX keyword
95
+ case 969: // ORA-00969: missing ON keyword
96
+ case 970: // ORA-00970: missing WITH keyword
97
+ case 971: // ORA-00971: missing SET keyword
98
+ case 972: // ORA-00972: identifier is too long
99
+ case 974: // ORA-00974: invalid PCTFREE value percentage
100
+ case 975: // ORA-00975: date + date not allowed
101
+ case 976: // ORA-00976: LEVEL, PRIOR, or ROWNUM not allowed here
102
+ case 977: // ORA-00977: duplicate auditing option
103
+ case 978: // ORA-00978: nested group function without GROUP BY
104
+ case 979: // ORA-00979: not a GROUP BY expression
105
+ case 980: // ORA-00980: synonym translation is no longer valid
106
+ case 981: // ORA-00981: cannot mix table and system auditing options
107
+ case 982: // ORA-00982: missing plus sign
108
+ case 984: // ORA-00984: column not allowed here
109
+ case 985: // ORA-00985: invalid program name
110
+ case 986: // ORA-00986: missing or invalid group names(s)
111
+ case 987: // ORA-00987: missing or invalid username(s)
112
+ case 988: // ORA-00988: missing or invalid password(s)
113
+ case 989: // ORA-00989: too many passwords for usernames given
114
+ case 990: // ORA-00990: missing or invalid privilege
115
+ case 992: // ORA-00992: invalid format for REVOKE command
116
+ case 993: // ORA-00993: missing GRANT keyword
117
+ case 994: // ORA-00994: missing OPTION keyword
118
+ case 995: // ORA-00995: missing or invalid synonym identifier
119
+ case 996: // ORA-00996: the concatenate operator is ||, not |
120
+ case 997: // ORA-00997: illegal use of LONG datatype
121
+ case 998: // ORA-00998: must name this expression with a column alias
122
+ return new SyntaxErrorException(exception);
123
+ case 953: // ORA-00953: invalid index name
124
+ case 999: // ORA-00999: invalid view name
125
+ case 4063: // ORA-04063: <object> has errors
126
+ return new DatabaseObjectNotFoundException(exception);
127
+ case 2291: // ORA-02291: integrity constraint violated - parent key not found
128
+ case 2292: // ORA-02292: integrity constraint violated - child record found
129
+ return new ForeignKeyConstraintViolationException(exception);
130
+ case 903: // ORA-00903: invalid table name
131
+ case 942: // ORA-00942: table or view does not exist
132
+ return new TableNotFoundException(exception);
133
+ case 955: // ORA-00955: name is already used by an existing object
134
+ return new TableExistsException(exception);
135
+ case 1400: // ORA-01400: cannot insert null into
136
+ return new NotNullConstraintViolationException(exception);
137
+ case 2290: // ORA-02290: check constraint violated
138
+ return new CheckConstraintViolationException(exception);
139
+ case 16000: // ORA-16000 Database open for read only access
140
+ return new ReadOnlyException(exception);
141
+ }
142
+ return super.convertException(exception);
143
+ }
144
+ }
145
+ /* v8 ignore stop */
@@ -0,0 +1,18 @@
1
+ import { MikroORM, type Options, type IDatabaseDriver, type EntityManager, type EntityManagerType, type EntityClass, type AnyEntity, type EntitySchema } from '@mikro-orm/core';
2
+ import type { SqlEntityManager } from '@mikro-orm/sql';
3
+ import { OracleDriver } from './OracleDriver.js';
4
+ export type OracleOptions<EM extends SqlEntityManager<OracleDriver> = SqlEntityManager<OracleDriver>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> = Options<OracleDriver, EM, Entities>;
5
+ export declare function defineOracleConfig<EM extends SqlEntityManager<OracleDriver> = SqlEntityManager<OracleDriver>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Options<OracleDriver, EM, Entities>): Options<OracleDriver, EM, Entities>;
6
+ /**
7
+ * @inheritDoc
8
+ */
9
+ export declare class OracleMikroORM<EM extends SqlEntityManager<OracleDriver> = SqlEntityManager<OracleDriver>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> extends MikroORM<OracleDriver, EM, Entities> {
10
+ /**
11
+ * @inheritDoc
12
+ */
13
+ static init<D extends IDatabaseDriver = OracleDriver, EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Options<D, EM, Entities>): Promise<MikroORM<D, EM, Entities>>;
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ constructor(options: Options<OracleDriver, EM, Entities>);
18
+ }
@@ -0,0 +1,22 @@
1
+ import { defineConfig, MikroORM, } from '@mikro-orm/core';
2
+ import { OracleDriver } from './OracleDriver.js';
3
+ export function defineOracleConfig(options) {
4
+ return defineConfig({ driver: OracleDriver, ...options });
5
+ }
6
+ /**
7
+ * @inheritDoc
8
+ */
9
+ export class OracleMikroORM extends MikroORM {
10
+ /**
11
+ * @inheritDoc
12
+ */
13
+ static async init(options) {
14
+ return super.init(defineOracleConfig(options));
15
+ }
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ constructor(options) {
20
+ super(defineOracleConfig(options));
21
+ }
22
+ }
@@ -0,0 +1,120 @@
1
+ import { AbstractSqlPlatform, type Dictionary, type EntityKey, type EntityManager, type EntityValue, type FilterQuery, type IDatabaseDriver, type IsolationLevel, type MikroORM, OracleNativeQueryBuilder, Type } from '@mikro-orm/sql';
2
+ import { OracleSchemaHelper } from './OracleSchemaHelper.js';
3
+ import { OracleExceptionConverter } from './OracleExceptionConverter.js';
4
+ import { OracleSchemaGenerator } from './OracleSchemaGenerator.js';
5
+ export declare class OraclePlatform extends AbstractSqlPlatform {
6
+ protected readonly schemaHelper: OracleSchemaHelper;
7
+ protected readonly exceptionConverter: OracleExceptionConverter;
8
+ /** @inheritDoc */
9
+ lookupExtensions(orm: MikroORM): void;
10
+ getRollbackToSavepointSQL(savepointName: string): string;
11
+ getSavepointSQL(savepointName: string): string;
12
+ getBeginTransactionSQL(options?: {
13
+ isolationLevel?: IsolationLevel;
14
+ readOnly?: boolean;
15
+ }): string[];
16
+ usesAsKeyword(): boolean;
17
+ compareUuids(): string;
18
+ convertUuidToJSValue(value: Buffer): string;
19
+ convertUuidToDatabaseValue(value: string): Buffer;
20
+ /** @internal */
21
+ createNativeQueryBuilder(): OracleNativeQueryBuilder;
22
+ usesOutputStatement(): boolean;
23
+ usesReturningStatement(): boolean;
24
+ convertsJsonAutomatically(): boolean;
25
+ indexForeignKeys(): boolean;
26
+ supportsSchemas(): boolean;
27
+ getCurrentTimestampSQL(length: number): string;
28
+ getDateTimeTypeDeclarationSQL(column: {
29
+ length?: number;
30
+ }): string;
31
+ getDefaultDateTimeLength(): number;
32
+ getFloatDeclarationSQL(): string;
33
+ getDoubleDeclarationSQL(): string;
34
+ getDecimalTypeDeclarationSQL(column: {
35
+ precision?: number;
36
+ scale?: number;
37
+ }): string;
38
+ getBooleanTypeDeclarationSQL(): string;
39
+ getRegExpOperator(): string;
40
+ mapRegExpCondition(mappedKey: string, value: {
41
+ $re: string;
42
+ $flags?: string;
43
+ }): {
44
+ sql: string;
45
+ params: unknown[];
46
+ };
47
+ getBlobDeclarationSQL(): string;
48
+ getJsonDeclarationSQL(): string;
49
+ getDefaultSchemaName(): string | undefined;
50
+ getVarcharTypeDeclarationSQL(column: {
51
+ length?: number;
52
+ }): string;
53
+ getDateTypeDeclarationSQL(length?: number): string;
54
+ getTimeTypeDeclarationSQL(length?: number): string;
55
+ getIntegerTypeDeclarationSQL(column: {
56
+ length?: number;
57
+ unsigned?: boolean;
58
+ autoincrement?: boolean;
59
+ }): string;
60
+ /**
61
+ * @inheritDoc
62
+ */
63
+ getBigIntTypeDeclarationSQL(column: {
64
+ length?: number;
65
+ unsigned?: boolean;
66
+ autoincrement?: boolean;
67
+ }): string;
68
+ getMediumIntTypeDeclarationSQL(column: {
69
+ length?: number;
70
+ unsigned?: boolean;
71
+ autoincrement?: boolean;
72
+ }): string;
73
+ getTinyIntTypeDeclarationSQL(column: {
74
+ length?: number;
75
+ unsigned?: boolean;
76
+ autoincrement?: boolean;
77
+ }): string;
78
+ getSmallIntTypeDeclarationSQL(column: {
79
+ length?: number;
80
+ unsigned?: boolean;
81
+ autoincrement?: boolean;
82
+ }): string;
83
+ getArrayDeclarationSQL(): string;
84
+ getEnumTypeDeclarationSQL(column: {
85
+ items?: unknown[];
86
+ fieldNames: string[];
87
+ length?: number;
88
+ unsigned?: boolean;
89
+ autoincrement?: boolean;
90
+ }): string;
91
+ getTextTypeDeclarationSQL(_column: {
92
+ length?: number;
93
+ }): string;
94
+ normalizeColumnType(type: string, options: {
95
+ length?: number;
96
+ precision?: number;
97
+ scale?: number;
98
+ }): string;
99
+ getDefaultMappedType(type: string): Type<unknown>;
100
+ getUuidTypeDeclarationSQL(column: {
101
+ length?: number;
102
+ }): string;
103
+ usesCascadeStatement(): boolean;
104
+ getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean, value?: unknown): string;
105
+ processJsonCondition<T extends object>(o: FilterQuery<T>, value: EntityValue<T>, path: EntityKey<T>[], alias: boolean): FilterQuery<T>;
106
+ usesEnumCheckConstraints(): boolean;
107
+ supportsMultipleCascadePaths(): boolean;
108
+ /** @inheritDoc */
109
+ supportsOnUpdate(): boolean;
110
+ supportsMultipleStatements(): boolean;
111
+ quoteIdentifier(id: string): string;
112
+ escape(value: any): string;
113
+ getSchemaGenerator(driver: IDatabaseDriver, em?: EntityManager): OracleSchemaGenerator;
114
+ allowsComparingTuples(): boolean;
115
+ getDefaultClientUrl(): string;
116
+ /** @internal */
117
+ mapToBindType(type: string): unknown;
118
+ mapToOracleType(type: string): unknown;
119
+ createOutBindings(map: Dictionary<string>): Dictionary;
120
+ }