Skip to content

Commit 17f14f4

Browse files
committed
Add warning for native bindings
1 parent edef4fe commit 17f14f4

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/native/query.js

+5
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ NativeQuery.prototype.submit = function(client) {
8585

8686
//named query
8787
if(this.name) {
88+
if (this.name.length > 63) {
89+
console.error('Warning! Postgres only supports 63 characters for query names.');
90+
console.error('You supplied', this.name, '(', this.name.length, ')');
91+
console.error('This can cause conflicts and silent errors executing queries');
92+
}
8893
var values = (this.values||[]).map(utils.prepareValue);
8994

9095
//check if the client has already executed this named query
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var helper = require(__dirname + '/../test-helper');
2+
3+
helper.pg.connect(helper.config, function(err,client) {
4+
var q = {
5+
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',
6+
text: 'SELECT NOW()'
7+
};
8+
client.query(q, function() {
9+
client.end();
10+
});
11+
});

0 commit comments

Comments
 (0)