Skip to content

Commit

Permalink
Test for empty and undefined values parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
dresende committed Nov 16, 2012
1 parent ab18e26 commit 0890a16
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/integration/connection/test-custom-query-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var connection = common.createConnection();
var assert = require('assert');

connection.config.queryFormat = function (query, values, tz) {
if (!values) return query;
return query.replace(/\:(\w+)/g, function (txt, key) {
if (values.hasOwnProperty(key)) {
return connection.escape(values[key]);
Expand All @@ -13,3 +14,5 @@ connection.config.queryFormat = function (query, values, tz) {
};

assert.equal(connection.format("SELECT :a1, :a2", { a1: 1, a2: 'two' }), "SELECT 1, 'two'");
assert.equal(connection.format("SELECT :a1", []), "SELECT :a1");
assert.equal(connection.format("SELECT :a1"), "SELECT :a1");

0 comments on commit 0890a16

Please sign in to comment.