@mikro-orm/knex 6.0.0-dev.317 → 6.0.0-dev.318

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.
@@ -37,13 +37,8 @@ class AbstractSqlConnection extends core_1.Connection {
37
37
  * @inheritDoc
38
38
  */
39
39
  async isConnected() {
40
- try {
41
- await this.getKnex().raw('select 1');
42
- return true;
43
- }
44
- catch {
45
- return false;
46
- }
40
+ const check = await this.checkConnection();
41
+ return check.ok;
47
42
  }
48
43
  /**
49
44
  * @inheritDoc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.0.0-dev.317",
3
+ "version": "6.0.0-dev.318",
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
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -66,6 +66,6 @@
66
66
  "@mikro-orm/core": "^5.0.0"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.0.0-dev.317"
69
+ "@mikro-orm/core": "6.0.0-dev.318"
70
70
  }
71
71
  }
@@ -21,7 +21,7 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
21
21
  */
22
22
  async ensureDatabase(options) {
23
23
  const dbName = this.config.get('dbName');
24
- if (this.lastEnsuredDatabase === dbName) {
24
+ if (this.lastEnsuredDatabase === dbName && !options?.forceCheck) {
25
25
  return true;
26
26
  }
27
27
  const exists = await this.helper.databaseExists(this.connection, dbName);
@@ -376,7 +376,10 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
376
376
  * creates new database and connects to it
377
377
  */
378
378
  async createDatabase(name) {
379
- await this.driver.execute(this.helper.getCreateDatabaseSQL('' + this.knex.ref(name)));
379
+ const sql = this.helper.getCreateDatabaseSQL('' + this.knex.ref(name));
380
+ if (sql) {
381
+ await this.driver.execute(sql);
382
+ }
380
383
  this.config.set('dbName', name);
381
384
  await this.driver.reconnect();
382
385
  }