test-procedure-with-single-select.js 792 B

12345678910111213141516171819202122232425262728293031323334
  1. var common = require('../../common');
  2. var connection = common.createConnection();
  3. var assert = require('assert');
  4. common.useTestDb(connection);
  5. var procedureName = 'singleSelectProcedure';
  6. var input = 1;
  7. var fieldName = 'param';
  8. var result = undefined;
  9. connection.query([
  10. 'CREATE DEFINER=root@localhost PROCEDURE '+procedureName+'(IN '+fieldName+' INT)',
  11. 'BEGIN',
  12. 'SELECT '+fieldName+';',
  13. 'END'
  14. ].join('\n'));
  15. connection.query('CALL '+procedureName+'(?)', [input], function(err, _result) {
  16. if (err) throw err;
  17. _result.pop(); // drop metadata
  18. result = _result;
  19. });
  20. connection.query('DROP PROCEDURE '+procedureName);
  21. connection.end();
  22. process.on('exit', function() {
  23. var expected = {};
  24. expected[fieldName] = input;
  25. assert.deepEqual(result, [[expected]]);
  26. });