[CONJS-115] Passing an empty array to batch throw an unexpected error Created: 2020-01-06 Updated: 2020-01-07 Resolved: 2020-01-07 |
|
| Status: | Closed |
| Project: | MariaDB Connector/node.js |
| Component/s: | API |
| Affects Version/s: | None |
| Fix Version/s: | 2.1.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Diego Dupin | Assignee: | Diego Dupin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
see https://github.com/mariadb-corporation/mariadb-connector-nodejs/issues/94:
This arguably shouldn't reject since the idea of a batch is to apply the query to all elements in the array (which are themselves arrays) and an empty array should result in no queries being executed. But the larger issue comes from calling pool.batch('INSERT INTO ...', [ ]) The promise rejects with the same error as above. But an uncaught error is also thrown:
This uncaught error crashes the node process (unless process.on('uncaughtException', ...) is used). The expected behavior is for the library to never throw an uncaught error. I would guess the bug relates to Usually an array of array, but in cases of only one placeholder per value, it can be given as a single array. i.e. the second argument is handled differently for pool.batch than for connection.batch |