Fix over-eager deprecation warnings (#1333)

* WIP

* Remove console.log messages
remotes/origin/carto-7.x
Brian C 7 years ago committed by GitHub
parent f7a946155f
commit 842803c7ef

@ -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 () {

@ -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…
Cancel
Save