From 17f14f4e588342d48b304581a81822fbe53c5e14 Mon Sep 17 00:00:00 2001 From: brianc Date: Sun, 7 Jun 2015 10:20:48 -0400 Subject: [PATCH] Add warning for native bindings --- lib/native/query.js | 5 +++++ test/integration/gh-issues/787-tests.js | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 test/integration/gh-issues/787-tests.js diff --git a/lib/native/query.js b/lib/native/query.js index 29b77ba9..2c4bc47d 100644 --- a/lib/native/query.js +++ b/lib/native/query.js @@ -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 diff --git a/test/integration/gh-issues/787-tests.js b/test/integration/gh-issues/787-tests.js new file mode 100644 index 00000000..e75c6766 --- /dev/null +++ b/test/integration/gh-issues/787-tests.js @@ -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(); + }); +});