Handle multi-statement queries
See original GitHub issueWe need to be able to handle queries like this:
const query = `
CREATE TABLE ids(id integer);
INSERT INTO ids(id) values(1);
INSERT INTO ids(id) values(2);
`;
await client.query(query);
I’m not sure how to nicely handle results, currently QueryResult has rows property that stores data returned from query. One idea is to subclass QueryResult and create MultiQueryResult that has slight different API and leave it up to user to handle that properly.
Comments welcome
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Work with multi-statement queries | BigQuery - Google Cloud
A multi-statement query is a collection of SQL statements that you can execute in one request. With multi-statement queries you can run multiple...
Read more >Including multiple SQL statements in one query - IBM
To run a query with multiple statements, ensure that each statement is separated by a semicolon; then set the DSQEC_RUN_MQ global variable to...
Read more >Multiple Statements - Manual - PHP
Multiple statements or multi queries must be executed with mysqli::multi_query(). The individual statements of the statement string are separated by semicolon.
Read more >SQL Server multi-statement table-valued functions - SQLShack
In this article, we will learn multi-statement table-valued functions (MSTVFs) basics and then we will reinforce our learnings with case ...
Read more >node-mysql multiple statements in one query - Stack Overflow
Multiple statement queries ... To use this feature you have to enable it for your connection: var connection = mysql.createConnection({multipleStatements: true});.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

That’s a separate issue, I just want to prevent using multi-statement queries in
querybecause I don’t want to give itQueryResult | QueryResult[]return type. 95% of queries will be single queries and there’s really no need for devs to check every time if they got array or single result.@bartlomieju I made a pr now, its only a wip but it should show what i mean