@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 +21 -0
- package/OracleConnection.d.ts +11 -0
- package/OracleConnection.js +176 -0
- package/OracleDriver.d.ts +14 -0
- package/OracleDriver.js +80 -0
- package/OracleExceptionConverter.d.ts +7 -0
- package/OracleExceptionConverter.js +145 -0
- package/OracleMikroORM.d.ts +18 -0
- package/OracleMikroORM.js +22 -0
- package/OraclePlatform.d.ts +120 -0
- package/OraclePlatform.js +283 -0
- package/OracleQueryBuilder.d.ts +9 -0
- package/OracleQueryBuilder.js +85 -0
- package/OracleSchemaGenerator.d.ts +41 -0
- package/OracleSchemaGenerator.js +395 -0
- package/OracleSchemaHelper.d.ts +45 -0
- package/OracleSchemaHelper.js +591 -0
- package/README.md +391 -0
- package/index.d.ts +10 -0
- package/index.js +9 -0
- package/package.json +58 -0
- package/tsconfig.build.tsbuildinfo +1 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { AbstractSqlPlatform, ALIAS_REPLACEMENT, DoubleType, FloatType, markOutBindings, OracleNativeQueryBuilder, raw, Type, Utils, } from '@mikro-orm/sql';
|
|
2
|
+
import oracledb from 'oracledb';
|
|
3
|
+
import { OracleSchemaHelper } from './OracleSchemaHelper.js';
|
|
4
|
+
import { OracleExceptionConverter } from './OracleExceptionConverter.js';
|
|
5
|
+
import { OracleSchemaGenerator } from './OracleSchemaGenerator.js';
|
|
6
|
+
const ORACLE_TYPE_MAP = {
|
|
7
|
+
string: oracledb.DB_TYPE_VARCHAR,
|
|
8
|
+
number: oracledb.DB_TYPE_NUMBER,
|
|
9
|
+
Date: oracledb.DB_TYPE_DATE,
|
|
10
|
+
boolean: oracledb.DB_TYPE_BOOLEAN,
|
|
11
|
+
buffer: oracledb.DB_TYPE_RAW,
|
|
12
|
+
Buffer: oracledb.DB_TYPE_RAW,
|
|
13
|
+
out: oracledb.BIND_OUT,
|
|
14
|
+
};
|
|
15
|
+
export class OraclePlatform extends AbstractSqlPlatform {
|
|
16
|
+
schemaHelper = new OracleSchemaHelper(this);
|
|
17
|
+
exceptionConverter = new OracleExceptionConverter();
|
|
18
|
+
/** @inheritDoc */
|
|
19
|
+
lookupExtensions(orm) {
|
|
20
|
+
OracleSchemaGenerator.register(orm);
|
|
21
|
+
}
|
|
22
|
+
getRollbackToSavepointSQL(savepointName) {
|
|
23
|
+
return `rollback to savepoint ${this.quoteIdentifier(savepointName)}`;
|
|
24
|
+
}
|
|
25
|
+
getSavepointSQL(savepointName) {
|
|
26
|
+
return `savepoint ${this.quoteIdentifier(savepointName)}`;
|
|
27
|
+
}
|
|
28
|
+
getBeginTransactionSQL(options) {
|
|
29
|
+
const parts = [];
|
|
30
|
+
if (options?.isolationLevel) {
|
|
31
|
+
parts.push(`isolation level ${options.isolationLevel}`);
|
|
32
|
+
}
|
|
33
|
+
if (options?.readOnly) {
|
|
34
|
+
parts.push('read only');
|
|
35
|
+
}
|
|
36
|
+
if (parts.length > 0) {
|
|
37
|
+
return [`set transaction ${parts.join(' ')}`];
|
|
38
|
+
}
|
|
39
|
+
return ['begin'];
|
|
40
|
+
}
|
|
41
|
+
usesAsKeyword() {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
compareUuids() {
|
|
45
|
+
return 'any';
|
|
46
|
+
}
|
|
47
|
+
convertUuidToJSValue(value) {
|
|
48
|
+
const hex = value.toString('hex');
|
|
49
|
+
return (hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16) + '-' + hex.slice(16, 20) + '-' + hex.slice(20));
|
|
50
|
+
}
|
|
51
|
+
convertUuidToDatabaseValue(value) {
|
|
52
|
+
if (Buffer.isBuffer(value)) {
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
if (typeof value !== 'string') {
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
return Buffer.from(value.replaceAll('-', ''), 'hex');
|
|
59
|
+
}
|
|
60
|
+
/** @internal */
|
|
61
|
+
createNativeQueryBuilder() {
|
|
62
|
+
return new OracleNativeQueryBuilder(this);
|
|
63
|
+
}
|
|
64
|
+
usesOutputStatement() {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
usesReturningStatement() {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
convertsJsonAutomatically() {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
indexForeignKeys() {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
supportsSchemas() {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
getCurrentTimestampSQL(length) {
|
|
80
|
+
return `current_timestamp`;
|
|
81
|
+
}
|
|
82
|
+
getDateTimeTypeDeclarationSQL(column) {
|
|
83
|
+
return 'timestamp' + (column.length != null ? `(${column.length})` : '') + ' with time zone';
|
|
84
|
+
}
|
|
85
|
+
getDefaultDateTimeLength() {
|
|
86
|
+
return 6;
|
|
87
|
+
}
|
|
88
|
+
getFloatDeclarationSQL() {
|
|
89
|
+
return 'binary_float';
|
|
90
|
+
}
|
|
91
|
+
getDoubleDeclarationSQL() {
|
|
92
|
+
return 'binary_double';
|
|
93
|
+
}
|
|
94
|
+
getDecimalTypeDeclarationSQL(column) {
|
|
95
|
+
return `number(${column.precision ?? 10}, ${column.scale ?? 0})`;
|
|
96
|
+
}
|
|
97
|
+
getBooleanTypeDeclarationSQL() {
|
|
98
|
+
return 'boolean';
|
|
99
|
+
}
|
|
100
|
+
getRegExpOperator() {
|
|
101
|
+
return 'regexp_like';
|
|
102
|
+
}
|
|
103
|
+
mapRegExpCondition(mappedKey, value) {
|
|
104
|
+
const quotedKey = this.quoteIdentifier(mappedKey);
|
|
105
|
+
/* v8 ignore next: $flags branch */
|
|
106
|
+
const quotedFlags = value.$flags ? `, ${this.quoteValue(value.$flags)}` : '';
|
|
107
|
+
return { sql: `regexp_like(${quotedKey}, ?${quotedFlags})`, params: [value.$re] };
|
|
108
|
+
}
|
|
109
|
+
getBlobDeclarationSQL() {
|
|
110
|
+
return 'blob';
|
|
111
|
+
}
|
|
112
|
+
getJsonDeclarationSQL() {
|
|
113
|
+
return 'json';
|
|
114
|
+
}
|
|
115
|
+
getDefaultSchemaName() {
|
|
116
|
+
return this.config.get('dbName');
|
|
117
|
+
}
|
|
118
|
+
getVarcharTypeDeclarationSQL(column) {
|
|
119
|
+
return `varchar2(${column.length ?? this.getDefaultVarcharLength()})`;
|
|
120
|
+
}
|
|
121
|
+
getDateTypeDeclarationSQL(length) {
|
|
122
|
+
return this.getVarcharTypeDeclarationSQL({ length: length ?? 10 });
|
|
123
|
+
}
|
|
124
|
+
getTimeTypeDeclarationSQL(length) {
|
|
125
|
+
return this.getVarcharTypeDeclarationSQL({ length: length ?? 8 });
|
|
126
|
+
}
|
|
127
|
+
getIntegerTypeDeclarationSQL(column) {
|
|
128
|
+
return `number(${column.length ?? 10}, 0)`;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @inheritDoc
|
|
132
|
+
*/
|
|
133
|
+
getBigIntTypeDeclarationSQL(column) {
|
|
134
|
+
return this.getIntegerTypeDeclarationSQL({ ...column, length: column.length ?? 19 });
|
|
135
|
+
}
|
|
136
|
+
getMediumIntTypeDeclarationSQL(column) {
|
|
137
|
+
return this.getIntegerTypeDeclarationSQL({ ...column, length: column.length ?? 7 });
|
|
138
|
+
}
|
|
139
|
+
getTinyIntTypeDeclarationSQL(column) {
|
|
140
|
+
return this.getIntegerTypeDeclarationSQL({ ...column, length: column.length ?? 3 });
|
|
141
|
+
}
|
|
142
|
+
getSmallIntTypeDeclarationSQL(column) {
|
|
143
|
+
return this.getIntegerTypeDeclarationSQL({ ...column, length: column.length ?? 5 });
|
|
144
|
+
}
|
|
145
|
+
getArrayDeclarationSQL() {
|
|
146
|
+
return 'clob';
|
|
147
|
+
}
|
|
148
|
+
getEnumTypeDeclarationSQL(column) {
|
|
149
|
+
if (column.items?.every(item => typeof item === 'string')) {
|
|
150
|
+
const length = column.length ?? Math.max(...column.items.map(item => item.length));
|
|
151
|
+
return this.getVarcharTypeDeclarationSQL({ length });
|
|
152
|
+
}
|
|
153
|
+
return this.getSmallIntTypeDeclarationSQL(column);
|
|
154
|
+
}
|
|
155
|
+
getTextTypeDeclarationSQL(_column) {
|
|
156
|
+
return 'clob';
|
|
157
|
+
}
|
|
158
|
+
normalizeColumnType(type, options) {
|
|
159
|
+
const simpleType = this.extractSimpleType(type);
|
|
160
|
+
// Oracle uses 'number' for all numeric types including integer, decimal, etc.
|
|
161
|
+
if (['decimal', 'numeric', 'number'].includes(simpleType)) {
|
|
162
|
+
return this.getDecimalTypeDeclarationSQL(options);
|
|
163
|
+
}
|
|
164
|
+
if (['real'].includes(simpleType)) {
|
|
165
|
+
return this.getFloatDeclarationSQL();
|
|
166
|
+
}
|
|
167
|
+
return super.normalizeColumnType(type, options);
|
|
168
|
+
}
|
|
169
|
+
getDefaultMappedType(type) {
|
|
170
|
+
if (type.startsWith('float')) {
|
|
171
|
+
const len = /float\((\d+)\)/.exec(type)?.[1] ?? 24;
|
|
172
|
+
return +len > 24 ? Type.getType(DoubleType) : Type.getType(FloatType);
|
|
173
|
+
}
|
|
174
|
+
const normalizedType = this.extractSimpleType(type);
|
|
175
|
+
const map = {
|
|
176
|
+
int: 'integer',
|
|
177
|
+
real: 'float',
|
|
178
|
+
raw: 'uuid',
|
|
179
|
+
binary_float: 'float',
|
|
180
|
+
binary_double: 'double',
|
|
181
|
+
nvarchar2: 'string',
|
|
182
|
+
nclob: 'text',
|
|
183
|
+
};
|
|
184
|
+
return super.getDefaultMappedType(map[normalizedType] ?? type);
|
|
185
|
+
}
|
|
186
|
+
getUuidTypeDeclarationSQL(column) {
|
|
187
|
+
return 'raw(16)';
|
|
188
|
+
}
|
|
189
|
+
/* v8 ignore next 3: Oracle overrides all callers but this is part of the platform contract */
|
|
190
|
+
usesCascadeStatement() {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
getSearchJsonPropertyKey(path, type, aliased, value) {
|
|
194
|
+
const [a, ...b] = path;
|
|
195
|
+
const root = this.quoteIdentifier(aliased ? `${ALIAS_REPLACEMENT}.${a}` : a);
|
|
196
|
+
if (b.length === 0) {
|
|
197
|
+
return raw(`json_equal(${root}, json(?))`, [value]);
|
|
198
|
+
}
|
|
199
|
+
/* v8 ignore next: special-char JSON key quoting */
|
|
200
|
+
const quoteKey = (key) => (/^[a-z]\w*$/i.exec(key) ? key : `"${key}"`);
|
|
201
|
+
return raw(`json_value(${root}, '$.${b.map(quoteKey).join('.')}')`);
|
|
202
|
+
}
|
|
203
|
+
processJsonCondition(o, value, path, alias) {
|
|
204
|
+
if (Utils.isPlainObject(value) && !Object.keys(value).some(k => Utils.isOperator(k))) {
|
|
205
|
+
Utils.keys(value).forEach(k => {
|
|
206
|
+
this.processJsonCondition(o, value[k], [...path, k], alias);
|
|
207
|
+
});
|
|
208
|
+
return o;
|
|
209
|
+
}
|
|
210
|
+
if (Utils.isPlainObject(value) && Object.keys(value)[0] === '$eq') {
|
|
211
|
+
value = value.$eq;
|
|
212
|
+
}
|
|
213
|
+
const type = this.getJsonValueType(value);
|
|
214
|
+
const k = this.getSearchJsonPropertyKey(path, type, alias, value);
|
|
215
|
+
/* v8 ignore next: root-level JSON equality branch */
|
|
216
|
+
o[k] = path.length > 1 ? value : [];
|
|
217
|
+
return o;
|
|
218
|
+
}
|
|
219
|
+
usesEnumCheckConstraints() {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
supportsMultipleCascadePaths() {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
/** @inheritDoc */
|
|
226
|
+
supportsOnUpdate() {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
supportsMultipleStatements() {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
quoteIdentifier(id) {
|
|
233
|
+
return super.quoteIdentifier(id, '"');
|
|
234
|
+
}
|
|
235
|
+
escape(value) {
|
|
236
|
+
if (value === null) {
|
|
237
|
+
return 'null';
|
|
238
|
+
}
|
|
239
|
+
if (Array.isArray(value)) {
|
|
240
|
+
return value.map(v => this.escape(v)).join(', ');
|
|
241
|
+
}
|
|
242
|
+
if (typeof value === 'string') {
|
|
243
|
+
if (value.includes(`'`)) {
|
|
244
|
+
return `'${value.replaceAll(`'`, `''`)}'`;
|
|
245
|
+
}
|
|
246
|
+
return `'${value}'`;
|
|
247
|
+
}
|
|
248
|
+
if (Buffer.isBuffer(value)) {
|
|
249
|
+
return `hextoraw('${value.toString('hex')}')`;
|
|
250
|
+
}
|
|
251
|
+
if (value instanceof Date) {
|
|
252
|
+
return `timestamp '${value.toISOString().replace('T', ' ').substring(0, 23)} UTC'`;
|
|
253
|
+
}
|
|
254
|
+
return super.escape(value);
|
|
255
|
+
}
|
|
256
|
+
getSchemaGenerator(driver, em) {
|
|
257
|
+
return new OracleSchemaGenerator(em ?? driver);
|
|
258
|
+
}
|
|
259
|
+
allowsComparingTuples() {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
getDefaultClientUrl() {
|
|
263
|
+
return 'localhost:1521/freepdb1';
|
|
264
|
+
}
|
|
265
|
+
/** @internal */
|
|
266
|
+
mapToBindType(type) {
|
|
267
|
+
return this.mapToOracleType(type);
|
|
268
|
+
}
|
|
269
|
+
mapToOracleType(type) {
|
|
270
|
+
return ORACLE_TYPE_MAP[type] ?? oracledb.DB_TYPE_VARCHAR;
|
|
271
|
+
}
|
|
272
|
+
createOutBindings(map) {
|
|
273
|
+
const outBindings = {};
|
|
274
|
+
markOutBindings(outBindings);
|
|
275
|
+
for (const key of Object.keys(map)) {
|
|
276
|
+
outBindings[key] = {
|
|
277
|
+
dir: oracledb.BIND_OUT,
|
|
278
|
+
type: this.mapToOracleType(map[key]),
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
return outBindings;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AnyEntity, type Dictionary, type EntityMetadata, type LockMode, type RequiredEntityData } from '@mikro-orm/core';
|
|
2
|
+
import { type InsertQueryBuilder, type NativeQueryBuilder, type Field, QueryBuilder } from '@mikro-orm/sql';
|
|
3
|
+
export declare class OracleQueryBuilder<Entity extends object = AnyEntity, RootAlias extends string = never, Hint extends string = never, Context extends object = never> extends QueryBuilder<Entity, RootAlias, Hint, Context> {
|
|
4
|
+
insert(data: RequiredEntityData<Entity> | RequiredEntityData<Entity>[]): InsertQueryBuilder<Entity, RootAlias, Context>;
|
|
5
|
+
setLockMode(mode?: LockMode, tables?: string[]): this;
|
|
6
|
+
getNativeQuery(processVirtualEntity?: boolean): NativeQueryBuilder;
|
|
7
|
+
private convertLockTablesToColumnRefs;
|
|
8
|
+
protected processReturningStatement(qb: NativeQueryBuilder, meta?: EntityMetadata, data?: Dictionary, returning?: Field<any>[]): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { isRaw, raw, Utils, } from '@mikro-orm/core';
|
|
2
|
+
import { QueryBuilder, QueryType } from '@mikro-orm/sql';
|
|
3
|
+
export class OracleQueryBuilder extends QueryBuilder {
|
|
4
|
+
insert(data) {
|
|
5
|
+
for (const row of Utils.asArray(data)) {
|
|
6
|
+
if (this.mainAlias.meta && Object.keys(row).length === 0) {
|
|
7
|
+
// ensure that we insert at least one column, otherwise Oracle will throw an error
|
|
8
|
+
row[this.mainAlias.meta.primaryKeys[0]] = raw('default');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return this.init(QueryType.INSERT, data);
|
|
12
|
+
}
|
|
13
|
+
setLockMode(mode, tables) {
|
|
14
|
+
if (tables) {
|
|
15
|
+
this.convertLockTablesToColumnRefs(tables);
|
|
16
|
+
}
|
|
17
|
+
return super.setLockMode(mode, tables);
|
|
18
|
+
}
|
|
19
|
+
getNativeQuery(processVirtualEntity = true) {
|
|
20
|
+
const qb = super.getNativeQuery(processVirtualEntity);
|
|
21
|
+
// Convert lockTables from table aliases to column references for Oracle
|
|
22
|
+
// This handles the case where lockTables are auto-computed from joins
|
|
23
|
+
const lockTables = qb.options?.lockTables;
|
|
24
|
+
if (lockTables?.length) {
|
|
25
|
+
this.convertLockTablesToColumnRefs(lockTables);
|
|
26
|
+
}
|
|
27
|
+
return qb;
|
|
28
|
+
}
|
|
29
|
+
convertLockTablesToColumnRefs(tables) {
|
|
30
|
+
for (let i = 0; i < tables.length; i++) {
|
|
31
|
+
if (!tables[i].includes('.')) {
|
|
32
|
+
const aliasInfo = this._aliases[tables[i]];
|
|
33
|
+
/* v8 ignore next 3: defensive — alias always has meta when called from ORM */
|
|
34
|
+
if (aliasInfo?.meta) {
|
|
35
|
+
tables[i] += '.' + aliasInfo.meta.getPrimaryProp().fieldNames[0];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
processReturningStatement(qb, meta, data, returning) {
|
|
41
|
+
if (!meta || !data) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const arr = Utils.asArray(data);
|
|
45
|
+
// always respect explicit returning hint
|
|
46
|
+
if (returning && returning.length > 0) {
|
|
47
|
+
qb.returning(
|
|
48
|
+
/* v8 ignore next 8: non-string field branch */
|
|
49
|
+
returning.map(field => {
|
|
50
|
+
if (typeof field === 'string') {
|
|
51
|
+
const prop = this.helper.getProperty(field);
|
|
52
|
+
return [prop?.fieldNames[0] ?? field, prop?.runtimeType ?? 'string'];
|
|
53
|
+
}
|
|
54
|
+
return this.helper.mapper(field, this.type);
|
|
55
|
+
}));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (this.type === QueryType.INSERT) {
|
|
59
|
+
const returningProps = meta.hydrateProps
|
|
60
|
+
.filter(prop => prop.returning || (prop.persist !== false && ((prop.primary && prop.autoincrement) || prop.defaultRaw)))
|
|
61
|
+
.filter(prop => !(prop.fieldNames[0] in arr[0]) || isRaw(arr[0][prop.fieldNames[0]]));
|
|
62
|
+
if (returningProps.length > 0) {
|
|
63
|
+
qb.returning(returningProps.map(prop => [prop.fieldNames[0], prop.runtimeType]));
|
|
64
|
+
}
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
/* v8 ignore next: implicit fallthrough for non-INSERT/UPDATE types */
|
|
68
|
+
if (this.type === QueryType.UPDATE) {
|
|
69
|
+
const returningProps = meta.hydrateProps.filter(prop => prop.fieldNames && isRaw(arr[0][prop.fieldNames[0]]));
|
|
70
|
+
if (returningProps.length > 0) {
|
|
71
|
+
qb.returning(returningProps.map(prop => {
|
|
72
|
+
/* v8 ignore next 7: NativeQueryBuilder does not support raw fragments in returning yet */
|
|
73
|
+
if (prop.hasConvertToJSValueSQL) {
|
|
74
|
+
const aliased = this.platform.quoteIdentifier(prop.fieldNames[0]);
|
|
75
|
+
const sql = prop.customType.convertToJSValueSQL(aliased, this.platform) +
|
|
76
|
+
' as ' +
|
|
77
|
+
this.platform.quoteIdentifier(prop.fieldNames[0]);
|
|
78
|
+
return raw(sql);
|
|
79
|
+
}
|
|
80
|
+
return [prop.fieldNames[0], prop.runtimeType];
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type DropSchemaOptions, type MikroORM, type UpdateSchemaOptions, SchemaGenerator, DatabaseSchema, type EnsureDatabaseOptions, type ClearDatabaseOptions } from '@mikro-orm/sql';
|
|
2
|
+
import type { OracleSchemaHelper } from './OracleSchemaHelper.js';
|
|
3
|
+
import type { OracleConnection } from './OracleConnection.js';
|
|
4
|
+
export declare class OracleSchemaGenerator extends SchemaGenerator {
|
|
5
|
+
protected helper: OracleSchemaHelper;
|
|
6
|
+
protected connection: OracleConnection;
|
|
7
|
+
/** Tracks whether the main user has been granted DBA (or equivalent) privileges. */
|
|
8
|
+
private hasDbaGrant;
|
|
9
|
+
static register(orm: MikroORM): void;
|
|
10
|
+
/**
|
|
11
|
+
* creates new database and connects to it
|
|
12
|
+
*/
|
|
13
|
+
createDatabase(name?: string): Promise<void>;
|
|
14
|
+
dropDatabase(name?: string): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Oracle uses CASCADE CONSTRAINT in DROP TABLE and has no native enums,
|
|
17
|
+
* so we can generate drop SQL from metadata alone — no DB introspection needed.
|
|
18
|
+
*/
|
|
19
|
+
getDropSchemaSQL(options?: Omit<DropSchemaOptions, 'dropDb'>): Promise<string>;
|
|
20
|
+
ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
|
|
21
|
+
private getOriginalUser;
|
|
22
|
+
/**
|
|
23
|
+
* Connects as the management (system) user if not already connected as admin.
|
|
24
|
+
* Returns the original user to restore later, or undefined if no reconnect was needed.
|
|
25
|
+
*/
|
|
26
|
+
private connectAsAdmin;
|
|
27
|
+
/**
|
|
28
|
+
* Restores the connection to the original user after admin operations.
|
|
29
|
+
*/
|
|
30
|
+
private restoreConnection;
|
|
31
|
+
/**
|
|
32
|
+
* Grants DBA (or fallback individual privileges) to the main user.
|
|
33
|
+
* Only executed once — subsequent calls are no-ops.
|
|
34
|
+
*/
|
|
35
|
+
private ensureDbaGrant;
|
|
36
|
+
createNamespace(name: string): Promise<void>;
|
|
37
|
+
dropNamespace(name: string): Promise<void>;
|
|
38
|
+
update(options?: UpdateSchemaOptions<DatabaseSchema>): Promise<void>;
|
|
39
|
+
clear(options?: ClearDatabaseOptions): Promise<void>;
|
|
40
|
+
private grantReferencesForSchema;
|
|
41
|
+
}
|