test-multiple-statements.js 744 B

1234567891011121314151617181920212223242526272829303132
  1. var common = require('../../common');
  2. var connection = common.createConnection({multipleStatements: true});
  3. var assert = require('assert');
  4. var sql = [
  5. 'SELECT 1',
  6. 'USE ' + common.testDatabase,
  7. 'SELECT 2',
  8. ].join('; ');
  9. var results;
  10. var fields;
  11. connection.query(sql, function(err, _results, _fields) {
  12. if (err) throw err;
  13. results = _results;
  14. fields = _fields;
  15. });
  16. connection.end();
  17. process.on('exit', function() {
  18. assert.equal(results.length, 3);
  19. assert.deepEqual(results[0], [{1: 1}]);
  20. assert.strictEqual(results[1].constructor.name, 'OkPacket');
  21. assert.deepEqual(results[2], [{2: 2}]);
  22. assert.equal(fields[0][0].name, '1');
  23. assert.equal(fields[1], undefined);
  24. assert.equal(fields[2][0].name, '2');
  25. });