Comparing version 0.1.15-alpha.0 to 0.1.16-alpha.0
@@ -7,3 +7,6 @@ const { Database } = require('../Database') | ||
disconnectDb = jest.fn() | ||
queryDb = jest.fn() | ||
queryDb = jest.fn().mockImplementation(async function (query) { | ||
return await this.runDatabaseOperation(() => {}) | ||
}) | ||
execDb = jest.fn() | ||
@@ -25,3 +28,2 @@ } | ||
) | ||
db.queryDb.mockResolvedValue() | ||
const promise = db.query('SELECT FUN FROM TESTS') | ||
@@ -38,3 +40,2 @@ expect(db.connectDb).toHaveBeenCalled() | ||
) | ||
db.queryDb.mockResolvedValue() | ||
const connectPromise = db.connect() | ||
@@ -52,3 +53,2 @@ db.query('SELECT FUN FROM TESTS') | ||
}) | ||
db.queryDb.mockResolvedValue() | ||
const connectPromise = db.connect() | ||
@@ -55,0 +55,0 @@ const queryPromise = db.query('SELECT FUN FROM TESTS') |
@@ -90,3 +90,6 @@ const { DatabaseMapper } = require('./DatabaseMapper') | ||
try { | ||
return await op() | ||
await this.waitForConnection() | ||
const result = await op() | ||
this.planDisconnect() | ||
return result | ||
} catch (e) { | ||
@@ -110,2 +113,3 @@ const ErrorType = this.resolveErrorType(e) | ||
async waitForConnection () { | ||
this.cancelDisconnectPlan() | ||
if (!this.connected) { | ||
@@ -123,15 +127,9 @@ if (this.connecting) { | ||
async query (str) { | ||
await this.waitForConnection() | ||
debug(str) | ||
const res = await this.queryDb(str) | ||
this.planDisconnect() | ||
return res | ||
return await this.queryDb(str) | ||
} | ||
async exec (str) { | ||
await this.waitForConnection() | ||
debug(str) | ||
const res = await this.execDb(str) | ||
this.planDisconnect() | ||
return res | ||
return await this.execDb(str) | ||
} | ||
@@ -138,0 +136,0 @@ |
@@ -9,3 +9,5 @@ const { Database } = require('./Database') | ||
if (db instanceof Database) { | ||
this.databases[dbName] = db | ||
if (!this.databases[dbName]) { | ||
this.databases[dbName] = db | ||
} | ||
} else { | ||
@@ -12,0 +14,0 @@ throw new DatabaseError( |
{ | ||
"name": "djorm", | ||
"version": "0.1.15-alpha.0", | ||
"version": "0.1.16-alpha.0", | ||
"description": "Django like ORM framework", | ||
@@ -39,3 +39,3 @@ "author": "Pavel Žák <pavel@zak.global>", | ||
}, | ||
"gitHead": "37b93ad465b7b9b4f1fc092fbd586271b510e79b" | ||
"gitHead": "9f2773dff72ecec64ee091b66e69f439c0a3da7a" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85010
2948