mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Merge pull request #787 from brianc/warn-on-long-query-names
Add warning on long query names
This commit is contained in:
commit
711adfe938
@ -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;
|
||||
|
||||
@ -85,6 +85,11 @@ NativeQuery.prototype.submit = function(client) {
|
||||
|
||||
//named query
|
||||
if(this.name) {
|
||||
if (this.name.length > 63) {
|
||||
console.error('Warning! Postgres only supports 63 characters for query names.');
|
||||
console.error('You supplied', this.name, '(', this.name.length, ')');
|
||||
console.error('This can cause conflicts and silent errors executing queries');
|
||||
}
|
||||
var values = (this.values||[]).map(utils.prepareValue);
|
||||
|
||||
//check if the client has already executed this named query
|
||||
|
||||
11
test/integration/gh-issues/787-tests.js
Normal file
11
test/integration/gh-issues/787-tests.js
Normal file
@ -0,0 +1,11 @@
|
||||
var helper = require(__dirname + '/../test-helper');
|
||||
|
||||
helper.pg.connect(helper.config, function(err,client) {
|
||||
var q = {
|
||||
name: 'This is a super long query name just so I can test that an error message is properly spit out to console.error without throwing an exception or anything',
|
||||
text: 'SELECT NOW()'
|
||||
};
|
||||
client.query(q, function() {
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user