Permalink
Browse files

Adds a simple test for escaping ids with "??"

  • Loading branch information...
1 parent 9517585 commit 938862663acce4e509b6778d8ad31bc6903b17c1 @dresende dresende committed Mar 15, 2013
Showing with 31 additions and 0 deletions.
  1. +31 −0 test/integration/connection/test-query-escape-id.js
View
31 test/integration/connection/test-query-escape-id.js
@@ -0,0 +1,31 @@
+var common = require('../../common');
+var connection = common.createConnection();
+var assert = require('assert');
+
+common.useTestDb(connection);
+
+var table = 'escape_id_test';
+connection.query([
+ 'CREATE TEMPORARY TABLE `' + table + '` (',
+ '`id` int(11) unsigned NOT NULL AUTO_INCREMENT,',
+ '`example` varchar(255),',
+ 'PRIMARY KEY (`id`)',
+ ') ENGINE=InnoDB DEFAULT CHARSET=utf8'
+].join('\n'));
+
+connection.query('INSERT INTO ?? SET ?? = ?, ?? = ?', [ table, 'id', 1, 'example', 'id escape']);
+
+var rows;
+connection.query('SELECT * FROM ??', [ table ], function(err, _rows) {
+ if (err) throw err;
+
+ rows = _rows;
+});
+
+connection.end();
+
+
+process.on('exit', function() {
+ assert.equal(rows.length, 1);
+ assert.deepEqual(rows[0], {id: 1, example: 'id escape'});
+});

0 comments on commit 9388626

Please sign in to comment.