test-procedure-with-multiple-selects.js 1018 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var common = require('../../common');
  2. var connection = common.createConnection();
  3. var assert = require('assert');
  4. common.useTestDb(connection);
  5. var procedureName = 'multipleSelectProcedure';
  6. var input0 = 1;
  7. var input1 = 1000;
  8. var fieldName0 = 'param0';
  9. var fieldName1 = 'param1';
  10. var result = undefined;
  11. connection.query([
  12. 'CREATE DEFINER=root@localhost PROCEDURE '+procedureName+'(IN '+fieldName0+' INT, IN '+fieldName1+' INT)',
  13. 'BEGIN',
  14. 'SELECT '+fieldName0+';',
  15. 'SELECT '+fieldName1+';',
  16. 'END'
  17. ].join('\n'));
  18. connection.query('CALL '+procedureName+'(?,?)', [input0,input1], function(err, _result) {
  19. if (err) throw err;
  20. _result.pop(); // drop metadata
  21. result = _result;
  22. });
  23. connection.query('DROP PROCEDURE '+procedureName);
  24. connection.end();
  25. process.on('exit', function() {
  26. var result0Expected = {};
  27. result0Expected[fieldName0] = input0;
  28. var result1Expected = {};
  29. result1Expected[fieldName1] = input1;
  30. assert.deepEqual(result, [[result0Expected], [result1Expected]]);
  31. });