test-multiple-statements-with-error.js 872 B

12345678910111213141516171819202122232425262728293031323334353637
  1. var common = require('../../common');
  2. var connection = common.createConnection({multipleStatements: true});
  3. var assert = require('assert');
  4. var sql = [
  5. 'SELECT 1',
  6. 'invalid sql',
  7. 'SELECT 2',
  8. ].join('; ');
  9. var finishedQueryOne = false;
  10. connection.query(sql, function(err, results, fields) {
  11. assert.equal(finishedQueryOne, false);
  12. finishedQueryOne = true;
  13. assert.equal(err.code, 'ER_PARSE_ERROR');
  14. assert.deepEqual(results, [[{1: 1}]]);
  15. assert.equal(fields.length, 1);
  16. assert.equal(fields[0][0].name, '1');
  17. });
  18. var finishedQueryTwo = false;
  19. connection.query('SELECT 3', function(err, results) {
  20. assert.equal(finishedQueryTwo, false);
  21. finishedQueryTwo = true;
  22. assert.deepEqual(results, [{3: 3}]);
  23. });
  24. connection.end();
  25. process.on('exit', function() {
  26. assert.equal(finishedQueryOne, true);
  27. assert.equal(finishedQueryTwo, true);
  28. });