Skip to content

Commit edef4fe

Browse files
committed
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: brianc#772
1 parent 540c3f1 commit edef4fe

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/connection.js

+5
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ Connection.prototype.parse = function(query, more) {
199199

200200
//normalize missing query names to allow for null
201201
query.name = query.name || '';
202+
if (query.name.length > 63) {
203+
console.error('Warning! Postgres only supports 63 characters for query names.');
204+
console.error('You supplied', query.name, '(', query.name.length, ')');
205+
console.error('This can cause conflicts and silent errors executing queries');
206+
}
202207
//normalize null type array
203208
query.types = query.types || [];
204209
var len = query.types.length;

0 commit comments

Comments
 (0)