A Twitch.tv viewer reward and games system.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
933 B

12 years ago
  1. var common = require('../../common');
  2. var connection = common.createConnection();
  3. var assert = require('assert');
  4. common.useTestDb(connection);
  5. var table = 'escape_test';
  6. connection.query([
  7. 'CREATE TEMPORARY TABLE `' + table + '` (',
  8. '`id` int(11) unsigned NOT NULL AUTO_INCREMENT,',
  9. '`example` varchar(255),',
  10. 'PRIMARY KEY (`id`)',
  11. ') ENGINE=InnoDB DEFAULT CHARSET=utf8'
  12. ].join('\n'));
  13. connection.query('INSERT INTO ' + table + ' SET id = ?, example = ?', [1, 'array escape']);
  14. connection.query('INSERT INTO ' + table + ' SET ?', {
  15. id: 2,
  16. example: 'object escape'
  17. });
  18. var rows;
  19. connection.query('SELECT * FROM escape_test', function(err, _rows) {
  20. if (err) throw err;
  21. rows = _rows;
  22. });
  23. connection.end();
  24. process.on('exit', function() {
  25. assert.equal(rows.length, 2);
  26. assert.deepEqual(rows[0], {id: 1, example: 'array escape'});
  27. assert.deepEqual(rows[1], {id: 2, example: 'object escape'});
  28. });