question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handle multi-statement queries

See original GitHub issue

We 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:closed
  • Created 5 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bartlomiejucommented, Feb 26, 2019

That’s a separate issue, I just want to prevent using multi-statement queries in query because I don’t want to give it QueryResult | 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.

0reactions
halvardssmcommented, Apr 21, 2020

@bartlomieju I made a pr now, its only a wip but it should show what i mean

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found