Comparing version 3.1.0 to 3.1.1
@@ -44,3 +44,6 @@ 'use strict'; | ||
const options = new PoolOptions(opts); | ||
return new PoolCallback(options); | ||
const pool = new PoolCallback(options); | ||
// adding a default error handler to avoid exiting application on connection error. | ||
pool.on('error', (err) => {}); | ||
return pool; | ||
}; | ||
@@ -47,0 +50,0 @@ |
@@ -148,7 +148,11 @@ 'use strict'; | ||
_createPool(options) { | ||
return new PoolPromise(options); | ||
const pool = new PoolPromise(options); | ||
pool.on('error', (err) => {}); | ||
return pool; | ||
} | ||
_createPoolCallback(options) { | ||
return new PoolCallback(options); | ||
const pool = new PoolCallback(options); | ||
pool.on('error', (err) => {}); | ||
return pool; | ||
} | ||
@@ -155,0 +159,0 @@ |
@@ -375,4 +375,10 @@ 'use strict'; | ||
this.bulkPacketNo--; | ||
if (val instanceof OkPacket) this._rows.push(val); | ||
// fast path doesn't push OkPacket if ony one results | ||
if (this._responseIndex === 0) { | ||
if (this.opts.metaAsArray) { | ||
if (val[0] instanceof OkPacket) this._rows.push(val[0]); | ||
} else if (val instanceof OkPacket) this._rows.push(val); | ||
} | ||
if (!this.sending && this.bulkPacketNo === 0) { | ||
@@ -401,15 +407,33 @@ this.packet = null; | ||
); | ||
this.successEnd(rs); | ||
this.successEnd(this.opts.metaAsArray ? [rs, []] : rs); | ||
} else { | ||
// insert with returning | ||
if (this._rows.length === 1) { | ||
this.successEnd(this._rows[0]); | ||
this.successEnd(this.opts.metaAsArray ? [this._rows[0], this._columns] : this._rows[0]); | ||
} | ||
if (this.opts.metaAsArray) { | ||
if (this._rows.length === 1) { | ||
this.successEnd([this._rows[0], this._columns]); | ||
} else { | ||
const rs = []; | ||
this._rows.forEach((row) => { | ||
rs.push(...row); | ||
}); | ||
this.successEnd([rs, this._columns]); | ||
} | ||
} else { | ||
const rs = []; | ||
rs.meta = this._rows[0].meta; | ||
this._rows.forEach((row) => { | ||
Array.prototype.push.apply(rs, row); | ||
}); | ||
rs.meta = this._rows[0].meta; | ||
this.successEnd(rs); | ||
// insert with returning | ||
if (this._rows.length === 1) { | ||
this.successEnd(this._rows[0]); | ||
} else { | ||
const rs = []; | ||
this._rows.forEach((row) => { | ||
rs.push(...row); | ||
}); | ||
Object.defineProperty(rs, 'meta', { | ||
value: this._columns, | ||
writable: true, | ||
enumerable: this.opts.metaEnumerable | ||
}); | ||
this.successEnd(rs); | ||
} | ||
} | ||
@@ -416,0 +440,0 @@ } |
@@ -114,3 +114,3 @@ 'use strict'; | ||
#readIdentifier(skip) { | ||
_readIdentifier(skip) { | ||
let pos = 0; | ||
@@ -156,7 +156,7 @@ while (skip-- > 0) { | ||
name() { | ||
return this.#readIdentifier(3); | ||
return this._readIdentifier(3); | ||
} | ||
db() { | ||
return this.#readIdentifier(0); | ||
return this._readIdentifier(0); | ||
} | ||
@@ -169,11 +169,11 @@ | ||
table() { | ||
return this.#readIdentifier(1); | ||
return this._readIdentifier(1); | ||
} | ||
orgTable() { | ||
return this.#readIdentifier(2); | ||
return this._readIdentifier(2); | ||
} | ||
orgName() { | ||
return this.#readIdentifier(4); | ||
return this._readIdentifier(4); | ||
} | ||
@@ -180,0 +180,0 @@ } |
@@ -182,3 +182,3 @@ 'use strict'; | ||
} | ||
return this.success(this.opts.metaAsArray ? [okPacket, [null]] : okPacket); | ||
return this.success(this.opts.metaAsArray ? [okPacket, []] : okPacket); | ||
} | ||
@@ -185,0 +185,0 @@ |
@@ -92,3 +92,3 @@ 'use strict'; | ||
//******************************************** | ||
this.paramWritten = this.#paramWritten.bind(this, out, info); | ||
this.paramWritten = this._paramWritten.bind(this, out, info); | ||
out.writeInt8(QUOTE); //' | ||
@@ -132,3 +132,3 @@ value.on('data', out.writeBufferEscape.bind(out)); | ||
const err = Errors.createError( | ||
`Cannot use timeout for MariaDB server before 10.1.2. timeout value: ${this.opts.timeout}`, | ||
`Cannot use timeout for xpand/MariaDB server before 10.1.2. timeout value: ${this.opts.timeout}`, | ||
Errors.ER_TIMEOUT_NOT_SUPPORTED, | ||
@@ -199,3 +199,3 @@ info, | ||
#paramWritten(out, info) { | ||
_paramWritten(out, info) { | ||
while (true) { | ||
@@ -231,3 +231,3 @@ if (this.valueIdx === this.paramPositions.length / 2) { | ||
out.writeInt8(QUOTE); | ||
this.#paramWritten(out, info); | ||
this._paramWritten(out, info); | ||
}.bind(this) | ||
@@ -234,0 +234,0 @@ ); |
@@ -208,2 +208,3 @@ 'use strict'; | ||
const executes = []; | ||
const cmdOpt = Object.assign({}, this.opts, cmdParam.opts); | ||
for (let i = 0; i < vals.length; i++) { | ||
@@ -219,3 +220,4 @@ executes.push(prepare.execute(vals[i], cmdParam.opts, null, cmdParam.stack)); | ||
// aggregate results | ||
const firstResult = res[0]; | ||
let firstResult = res[0]; | ||
if (cmdOpt.metaAsArray) firstResult = firstResult[0]; | ||
if (firstResult instanceof OkPacket) { | ||
@@ -225,16 +227,34 @@ let affectedRows = 0; | ||
const warningStatus = firstResult.warningStatus; | ||
for (let i = 0; i < res.length; i++) { | ||
affectedRows += res[i].affectedRows; | ||
if (cmdOpt.metaAsArray) { | ||
for (let i = 0; i < res.length; i++) { | ||
affectedRows += res[i][0].affectedRows; | ||
} | ||
return Promise.resolve([new OkPacket(affectedRows, insertId, warningStatus), []]); | ||
} else { | ||
for (let i = 0; i < res.length; i++) { | ||
affectedRows += res[i].affectedRows; | ||
} | ||
return Promise.resolve(new OkPacket(affectedRows, insertId, warningStatus)); | ||
} | ||
return Promise.resolve(new OkPacket(affectedRows, insertId, warningStatus)); | ||
} else { | ||
// results have result-set. example :'INSERT ... RETURNING' | ||
// aggregate results | ||
const rs = []; | ||
rs.meta = res.meta; | ||
res.forEach((row) => { | ||
Array.prototype.push.apply(rs, row); | ||
}); | ||
rs.meta = res.meta; | ||
return Promise.resolve(rs); | ||
if (cmdOpt.metaAsArray) { | ||
const rs = []; | ||
res.forEach((row) => { | ||
rs.push(...row[0]); | ||
}); | ||
return Promise.resolve([rs, res[0][1]]); | ||
} else { | ||
const rs = []; | ||
res.forEach((row) => { | ||
rs.push(...row); | ||
}); | ||
Object.defineProperty(rs, 'meta', { | ||
value: res[0].meta, | ||
writable: true, | ||
enumerable: this.opts.metaEnumerable | ||
}); | ||
return Promise.resolve(rs); | ||
} | ||
} | ||
@@ -343,2 +363,3 @@ } | ||
() => { | ||
conn.prepareCache.reset(); | ||
let prom = Promise.resolve(); | ||
@@ -345,0 +366,0 @@ // re-execute init query / session query timeout |
@@ -41,4 +41,8 @@ 'use strict'; | ||
} | ||
reset() { | ||
this.#lruCache.clear(); | ||
} | ||
} | ||
module.exports = LruPrepareCache; |
@@ -85,3 +85,3 @@ 'use strict'; | ||
const conn = new ConnectionPromise(baseConn); | ||
conn.release = this.#releaseConnection.bind(this, baseConn); | ||
conn.release = () => new Promise(baseConn.release); | ||
conn.end = conn.release; | ||
@@ -92,6 +92,2 @@ conn.close = conn.release; | ||
#releaseConnection(baseConn) { | ||
return new Promise(baseConn.release); | ||
} | ||
/** | ||
@@ -98,0 +94,0 @@ * Execute query using text protocol with callback emit columns/data/end/error |
@@ -31,3 +31,2 @@ 'use strict'; | ||
this.on('validateSize', this._sizeHandler); | ||
this._sizeHandler(); | ||
@@ -34,0 +33,0 @@ } |
{ | ||
"name": "mariadb", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "fast mariadb or mysql connector.", | ||
@@ -5,0 +5,0 @@ "main": "promise.js", |
@@ -42,3 +42,6 @@ 'use strict'; | ||
const options = new PoolOptions(opts); | ||
return new PoolPromise(options); | ||
const pool = new PoolPromise(options); | ||
// adding a default error handler to avoid exiting application on connection error. | ||
pool.on('error', (err) => {}); | ||
return pool; | ||
}; | ||
@@ -45,0 +48,0 @@ |
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
526380
14111