Add warning on long query names

Postgres has a 63 character limit on query names.  To avoid potential footgunning of users we'll log to their stderr if they use a longer query name.

For reference: https://github.com/brianc/node-postgres/pull/772
This commit is contained in:
brianc 2015-05-21 13:14:01 -04:00
parent 540c3f16db
commit edef4fee53

View File

@ -199,6 +199,11 @@ Connection.prototype.parse = function(query, more) {
//normalize missing query names to allow for null
query.name = query.name || '';
if (query.name.length > 63) {
console.error('Warning! Postgres only supports 63 characters for query names.');
console.error('You supplied', query.name, '(', query.name.length, ')');
console.error('This can cause conflicts and silent errors executing queries');
}
//normalize null type array
query.types = query.types || [];
var len = query.types.length;