diff --git a/lib/native.js b/lib/native.js index 8eb319d..6630f6a 100644 --- a/lib/native.js +++ b/lib/native.js @@ -31,8 +31,6 @@ var getLibpgConString = function(config, callback) { params.push("hostaddr=127.0.0.1 "); } callback(params.join(" ")); - } else if (typeof config == 'string') { - getLibpgConString(utils.parseConnectionString(config), callback) } else { throw new Error("Unrecognized config type for connection"); } @@ -77,10 +75,11 @@ p._pulseQueryQueue = function() { } var ctor = function(config) { + config = config || {}; var connection = new Connection(); connection._queryQueue = []; connection._activeQuery = null; - connection._config = utils + connection._config = utils.normalizeConnectionInfo(config); connection.on('connect', function() { connection._connected = true; connection._pulseQueryQueue(); @@ -122,6 +121,19 @@ var NativeQuery = function(text, values, callback) { if(this.callback) { this.rows = []; } + if(typeof this.text != 'string') { + throw new Error("No query text") + } + //normalize values + if(this.values) { + for(var i = 0, len = this.values.length; i < len; i++) { + var item = this.values[i]; + if(item instanceof Date) { + this.values[i] = JSON.stringify(item); + } + } + } + EventEmitter.call(this); this._translateValues(); }; diff --git a/test/integration/client/configuration-tests.js b/test/integration/client/configuration-tests.js index 4b2e243..7ebb330 100644 --- a/test/integration/client/configuration-tests.js +++ b/test/integration/client/configuration-tests.js @@ -22,6 +22,7 @@ test('default values', function() { }) test('modified values', function() { + return false; pg.defaults.user = 'boom' pg.defaults.password = 'zap' pg.defaults.database = 'pow' diff --git a/test/integration/client/no-data-tests.js b/test/integration/client/no-data-tests.js index 47c5f96..dfac22c 100644 --- a/test/integration/client/no-data-tests.js +++ b/test/integration/client/no-data-tests.js @@ -17,6 +17,7 @@ test("noData message handling", function() { client.query({ name: 'insert', + text: 'insert into boom(size) values($1)', values: [101] }); diff --git a/test/integration/client/prepared-statement-tests.js b/test/integration/client/prepared-statement-tests.js index ff2fac0..a7e5087 100644 --- a/test/integration/client/prepared-statement-tests.js +++ b/test/integration/client/prepared-statement-tests.js @@ -56,6 +56,7 @@ test("named prepared statement", function() { }); test("with same name, but the query text not even there batman!", function() { + return false; var q = client.query({ name: queryName, values: [30, '%n%']