mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-25 16:03:13 +00:00
Fix over-eager deprecation warnings (#1333)
* WIP * Remove console.log messages
This commit is contained in:
parent
f7a946155f
commit
842803c7ef
14
lib/query.js
14
lib/query.js
@ -57,8 +57,18 @@ Query.prototype.catch = function(callback) {
|
||||
Query.prototype._getPromise = function () {
|
||||
if (this._promise) return this._promise;
|
||||
this._promise = new Promise(function(resolve, reject) {
|
||||
this._once('end', resolve);
|
||||
this._once('error', reject);
|
||||
var onEnd = function (result) {
|
||||
this.removeListener('error', onError);
|
||||
this.removeListener('end', onEnd);
|
||||
resolve(result);
|
||||
};
|
||||
var onError = function (err) {
|
||||
this.removeListener('error', onError);
|
||||
this.removeListener('end', onEnd);
|
||||
reject(err);
|
||||
};
|
||||
this._on('end', onEnd);
|
||||
this._on('error', onError);
|
||||
}.bind(this));
|
||||
return this._promise;
|
||||
};
|
||||
|
||||
@ -139,7 +139,7 @@ function normalizeQueryConfig (config, values, callback) {
|
||||
return config;
|
||||
}
|
||||
|
||||
var queryEventEmitterOverloadDeprecationMessage = 'Using the automatically created return value from client.query as an event emitter is deprecated. Please see the upgrade guide at https://node-postgres.com/guides/upgrading';
|
||||
var queryEventEmitterOverloadDeprecationMessage = 'Using the automatically created return value from client.query as an event emitter is deprecated and will be removed in pg@7.0. Please see the upgrade guide at https://node-postgres.com/guides/upgrading';
|
||||
|
||||
var deprecateEventEmitter = function(Emitter) {
|
||||
var Result = function () {
|
||||
|
||||
22
test/integration/client/deprecation-tests.js
Normal file
22
test/integration/client/deprecation-tests.js
Normal file
@ -0,0 +1,22 @@
|
||||
var helper = require('./test-helper')
|
||||
process.noDeprecation = false
|
||||
process.on('warning', function () {
|
||||
throw new Error('Should not emit deprecation warning')
|
||||
})
|
||||
|
||||
var client = new helper.pg.Client()
|
||||
|
||||
client.connect(function (err) {
|
||||
if (err) throw err
|
||||
client.query('SELECT NOW()')
|
||||
.then(function (res) {
|
||||
client.query('SELECT NOW()', function () {
|
||||
client.end(function () {
|
||||
})
|
||||
})
|
||||
}).catch(function (err) {
|
||||
setImmediate(function () {
|
||||
throw err
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user