Comparing version 3.1.0 to 3.2.0
@@ -29,5 +29,7 @@ /* SQB | ||
* @param {Object} client | ||
* @param {Object} options | ||
* @param {Boolean} [options.autoCommit] | ||
* @constructor | ||
*/ | ||
constructor(pool, client) { | ||
constructor(pool, client, options) { | ||
super(); | ||
@@ -38,2 +40,3 @@ this._pool = pool; | ||
this._refCount = 1; | ||
this._autoCommit = options.autoCommit; | ||
this.on('error', (e) => { | ||
@@ -82,2 +85,11 @@ if (process.env.DEBUG) | ||
/** | ||
* Returns connection is in auto commit mode or not | ||
* | ||
* @return {Boolean} | ||
*/ | ||
get autoCommit() { | ||
return this._autoCommit; | ||
} | ||
/** | ||
* This call Executes a query | ||
@@ -84,0 +96,0 @@ * |
@@ -66,5 +66,3 @@ /* SQB | ||
/* Lightning pool arguments */ | ||
const options = config.pool || {}; | ||
options.resetOnReturn = true; | ||
/* Create object pool */ | ||
const factory = { | ||
@@ -83,3 +81,5 @@ create: () => adapter.createConnection(), | ||
}; | ||
super(factory, options); | ||
const poolOptions = config.pool || {}; | ||
poolOptions.resetOnReturn = true; | ||
super(factory, poolOptions); | ||
this.config = cfg; | ||
@@ -108,7 +108,15 @@ } | ||
* This method obtains a connection from the connection pool. | ||
* @param {Function} sessionFn | ||
* @param {Object} [options] | ||
* @param {Function} [sessionFn] | ||
* @return {Promise} | ||
*/ | ||
acquire(sessionFn) { | ||
acquire(options, sessionFn) { | ||
debug('acquire'); | ||
if (typeof options === 'function') { | ||
sessionFn = options; | ||
options = null; | ||
} | ||
options = options || {}; | ||
if (sessionFn && typeof sessionFn !== 'function') | ||
@@ -123,3 +131,7 @@ return Promise.reject(new ArgumentError('`sessionFn` argument can be only a function')); | ||
// Create new connection | ||
const connection = new Connection(this, client); | ||
const connection = new Connection(this, client, | ||
{ | ||
autoCommit: options.autoCommit != null ? options.autoCommit : | ||
(this.config.defaults && this.config.defaults.autoCommit) | ||
}); | ||
connection.once('closing', () => { | ||
@@ -126,0 +138,0 @@ super.release(client).then(() => connection.emitSafe('close')); |
@@ -44,3 +44,3 @@ /* SQB | ||
autoCommit: options.autoCommit != null ? options.autoCommit : | ||
defaults.autoCommit, | ||
connection.autoCommit, | ||
cursor: options.cursor != null ? options.cursor : defaults.cursor, | ||
@@ -47,0 +47,0 @@ objectRows: options.objectRows != null ? options.objectRows : |
@@ -86,4 +86,4 @@ /* SQB | ||
getTables(tableLike) { | ||
if (this._dbmeta.supportsSchemas) | ||
throw new Error('Can not query tables directly. Dialect supports schemas'); | ||
if (this._metaOp.supportsSchemas) | ||
return Promise.reject(new Error('Can not query tables directly. Dialect supports schemas')); | ||
return SchemaMeta.prototype.getTables.call(this, tableLike); | ||
@@ -90,0 +90,0 @@ } |
@@ -44,5 +44,5 @@ /* SQB | ||
if (this.meta && this.name) | ||
query.where(Op.eq('schema_name', this.name)); | ||
query.where({schema_name: this.name}); | ||
if (tableLike) | ||
query.where(Op.like('table_name', tableLike)); | ||
query.where({table_name: tableLike}); | ||
return query.execute({ | ||
@@ -49,0 +49,0 @@ cursor: false, |
{ | ||
"name": "sqb", | ||
"description": "Extensible, multi-dialect SQL query builder and Database connection framework for JavaScript", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"author": "Panates Ltd.", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
125552
4692