@mikro-orm/knex 7.0.0-dev.42 → 7.0.0-dev.43
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/AbstractSqlConnection.d.ts +3 -1
- package/AbstractSqlConnection.js +4 -1
- package/dialects/sqlite/BaseSqliteConnection.d.ts +4 -2
- package/dialects/sqlite/BaseSqliteConnection.js +2 -5
- package/package.json +2 -2
- package/schema/SqlSchemaGenerator.d.ts +3 -1
- package/schema/SqlSchemaGenerator.js +8 -8
|
@@ -6,7 +6,9 @@ export declare abstract class AbstractSqlConnection extends Connection {
|
|
|
6
6
|
protected platform: AbstractSqlPlatform;
|
|
7
7
|
protected client: Kysely<any>;
|
|
8
8
|
abstract createKyselyDialect(overrides: Dictionary): MaybePromise<Dialect>;
|
|
9
|
-
connect(
|
|
9
|
+
connect(options?: {
|
|
10
|
+
skipOnConnect?: boolean;
|
|
11
|
+
}): Promise<void>;
|
|
10
12
|
/**
|
|
11
13
|
* @inheritDoc
|
|
12
14
|
*/
|
package/AbstractSqlConnection.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Connection, EventType, RawQueryFragment, Utils, } from '@mikro-orm/core
|
|
|
4
4
|
import { NativeQueryBuilder } from './query/NativeQueryBuilder.js';
|
|
5
5
|
export class AbstractSqlConnection extends Connection {
|
|
6
6
|
client;
|
|
7
|
-
async connect() {
|
|
7
|
+
async connect(options) {
|
|
8
8
|
let driverOptions = this.options.driverOptions ?? this.config.get('driverOptions');
|
|
9
9
|
if (typeof driverOptions === 'function') {
|
|
10
10
|
driverOptions = await driverOptions();
|
|
@@ -23,6 +23,9 @@ export class AbstractSqlConnection extends Connection {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
this.connected = true;
|
|
26
|
+
if (options?.skipOnConnect !== true) {
|
|
27
|
+
await this.onConnect();
|
|
28
|
+
}
|
|
26
29
|
}
|
|
27
30
|
/**
|
|
28
31
|
* @inheritDoc
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AbstractSqlConnection } from '../../AbstractSqlConnection.js';
|
|
2
2
|
export declare abstract class BaseSqliteConnection extends AbstractSqlConnection {
|
|
3
|
-
connect(
|
|
4
|
-
|
|
3
|
+
connect(options?: {
|
|
4
|
+
skipOnConnect?: boolean;
|
|
5
|
+
simple?: boolean;
|
|
6
|
+
}): Promise<void>;
|
|
5
7
|
}
|
|
@@ -3,9 +3,9 @@ import { CompiledQuery } from 'kysely';
|
|
|
3
3
|
import { Utils } from '@mikro-orm/core';
|
|
4
4
|
import { AbstractSqlConnection } from '../../AbstractSqlConnection.js';
|
|
5
5
|
export class BaseSqliteConnection extends AbstractSqlConnection {
|
|
6
|
-
async connect(
|
|
6
|
+
async connect(options) {
|
|
7
7
|
await super.connect();
|
|
8
|
-
if (simple) {
|
|
8
|
+
if (options?.simple) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
const dbName = this.config.get('dbName');
|
|
@@ -14,7 +14,4 @@ export class BaseSqliteConnection extends AbstractSqlConnection {
|
|
|
14
14
|
}
|
|
15
15
|
await this.client.executeQuery(CompiledQuery.raw('pragma foreign_keys = on'));
|
|
16
16
|
}
|
|
17
|
-
getClientUrl() {
|
|
18
|
-
return '';
|
|
19
|
-
}
|
|
20
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "7.0.0-dev.
|
|
3
|
+
"version": "7.0.0-dev.43",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -57,6 +57,6 @@
|
|
|
57
57
|
"@mikro-orm/core": "^6.6.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@mikro-orm/core": "7.0.0-dev.
|
|
60
|
+
"@mikro-orm/core": "7.0.0-dev.43"
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -48,7 +48,9 @@ export declare class SqlSchemaGenerator extends AbstractSchemaGenerator<Abstract
|
|
|
48
48
|
/**
|
|
49
49
|
* creates new database and connects to it
|
|
50
50
|
*/
|
|
51
|
-
createDatabase(name?: string
|
|
51
|
+
createDatabase(name?: string, options?: {
|
|
52
|
+
skipOnConnect?: boolean;
|
|
53
|
+
}): Promise<void>;
|
|
52
54
|
dropDatabase(name?: string): Promise<void>;
|
|
53
55
|
execute(sql: string, options?: {
|
|
54
56
|
wrap?: boolean;
|
|
@@ -27,10 +27,8 @@ export class SqlSchemaGenerator extends AbstractSchemaGenerator {
|
|
|
27
27
|
const managementDbName = this.helper.getManagementDbName();
|
|
28
28
|
if (managementDbName) {
|
|
29
29
|
this.config.set('dbName', managementDbName);
|
|
30
|
-
await this.driver.reconnect();
|
|
31
|
-
await this.createDatabase(dbName);
|
|
32
|
-
this.config.set('dbName', dbName);
|
|
33
|
-
await this.driver.reconnect();
|
|
30
|
+
await this.driver.reconnect({ skipOnConnect: true });
|
|
31
|
+
await this.createDatabase(dbName, { skipOnConnect: true });
|
|
34
32
|
}
|
|
35
33
|
if (options?.create) {
|
|
36
34
|
await this.createSchema(options);
|
|
@@ -38,7 +36,7 @@ export class SqlSchemaGenerator extends AbstractSchemaGenerator {
|
|
|
38
36
|
return true;
|
|
39
37
|
}
|
|
40
38
|
if (options?.clear) {
|
|
41
|
-
await this.clearDatabase(options);
|
|
39
|
+
await this.clearDatabase({ ...options, clearIdentityMap: false });
|
|
42
40
|
}
|
|
43
41
|
return false;
|
|
44
42
|
}
|
|
@@ -120,7 +118,9 @@ export class SqlSchemaGenerator extends AbstractSchemaGenerator {
|
|
|
120
118
|
.execute();
|
|
121
119
|
}
|
|
122
120
|
await this.execute(this.helper.enableForeignKeysSQL());
|
|
123
|
-
|
|
121
|
+
if (options?.clearIdentityMap ?? true) {
|
|
122
|
+
this.clearIdentityMap();
|
|
123
|
+
}
|
|
124
124
|
}
|
|
125
125
|
async getDropSchemaSQL(options = {}) {
|
|
126
126
|
await this.ensureDatabase();
|
|
@@ -289,14 +289,14 @@ export class SqlSchemaGenerator extends AbstractSchemaGenerator {
|
|
|
289
289
|
/**
|
|
290
290
|
* creates new database and connects to it
|
|
291
291
|
*/
|
|
292
|
-
async createDatabase(name) {
|
|
292
|
+
async createDatabase(name, options) {
|
|
293
293
|
name ??= this.config.get('dbName');
|
|
294
294
|
const sql = this.helper.getCreateDatabaseSQL('' + this.platform.quoteIdentifier(name));
|
|
295
295
|
if (sql) {
|
|
296
296
|
await this.execute(sql);
|
|
297
297
|
}
|
|
298
298
|
this.config.set('dbName', name);
|
|
299
|
-
await this.driver.reconnect();
|
|
299
|
+
await this.driver.reconnect(options);
|
|
300
300
|
}
|
|
301
301
|
async dropDatabase(name) {
|
|
302
302
|
name ??= this.config.get('dbName');
|