diff --git a/lib/native.js b/lib/native.js index b8ff9e05..92614dd1 100644 --- a/lib/native.js +++ b/lib/native.js @@ -46,8 +46,8 @@ p.connect = function() { }) } -p.query = function(config) { - var q = new NativeQuery(config); +p.query = function(config, values) { + var q = new NativeQuery(config, values); this._queryQueue.push(q); this._pulseQueryQueue(); return q; diff --git a/src/binding.cc b/src/binding.cc index 1985b0c0..eb252e69 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -102,6 +102,10 @@ public: if(!args[0]->IsString()) { return ThrowException(Exception::Error(String::New("First parameter must be a string query"))); } + printf("testing for logs",""); + if(!args[1]->IsArray()) { + return ThrowException(Exception::Error(String::New("Values must be array"))); + } String::Utf8Value queryText(args[0]->ToString()); int result = self->Send(*queryText); diff --git a/test/native/error-tests.js b/test/native/error-tests.js index 1a83633f..0bc8a869 100644 --- a/test/native/error-tests.js +++ b/test/native/error-tests.js @@ -27,3 +27,35 @@ test('parameterized query with non-text as first parameter throws error', functi }) }) +var connect = function(callback) { + var client = new Client(conString); + client.connect(); + assert.emits(client, 'connect', function() { + callback(client); + }) +} + +test('parameterized query with non-array for second value', function() { + test('inline', function() { + connect(function(client) { + assert.throws(function() { + client.query("SELECT *", "LKSDJF") + }) + client.end(); + }) + }) + test('config', function() { + + connect(function(client) { + assert.throws(function() { + client.query({ + text: "SELECT *", + values: "ALSDKFJ" + }) + }) + client.end(); + }) + }) +}) + +