Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to execute multiple SQL statements at once #6

Merged
merged 3 commits into from
Aug 18, 2015

Conversation

peter-ss
Copy link
Contributor

Added support for multiple-statement execution via a new API: Database.executeMultiStatement().

Adjusted unit tests accordingly. Removed unit test for catching error when a multi-statement SQL string is handed to db.execute(), since the code halts with a message to the dev in that case, instead of throwing an error.

I’d be happy to update any documentation with examples of use, if you’d like.

@groue
Copy link
Owner

groue commented Aug 17, 2015

I'm no longer on vacation ;-)

Removed unit test for catching error when a multi-statement SQL string is handed to db.execute(), since the code halts with a message to the dev in that case, instead of throwing an error.

I don't get it: executeMultiStatement() throws, and it's good to test that the thrown error contains all the precious debugging information!

Besides this tiny nitpicking, I can already accept your PR right away.

I would still:

  • Extract UpdateStatement.Changes into DatabaseChanges,
  • Update README.md and RELEASE_NOTES.md

If you still feel inspired, go ahead. I can take it over if you prefer. You've already done a great job.

@peter-ss
Copy link
Contributor Author

Working on these right now...

On Mon, Aug 17, 2015 at 11:16 AM, Gwendal Roué [email protected]
wrote:

I'm no longer in vacation ;-)

Removed unit test for catching error when a multi-statement SQL string is
handed to db.execute(), since the code halts with a message to the dev in
that case, instead of throwing an error.

I don't get it: executeMultiStatement() throws, and it's good to test that
the thrown error contains all the precious debugging information!

Besides this tiny nitpicking, I can already accept your PR right away.

I would still:

  • Extract UpdateStatement.Changes into DatabaseChanges,
  • Update README.md and RELEASE_NOTES.md

If you still feel inspired, go ahead. I can take it over if you prefer.
You've already done a great job.


Reply to this email directly or view it on GitHub
#6 (comment).

Updated unit tests and README accordingly.
@peter-ss
Copy link
Contributor Author

OK - I made some of your suggested updates. Didn't update RELEASE_NOTES
because I couldn't find it. The PR is updated.

On Mon, Aug 17, 2015 at 11:16 AM, Gwendal Roué [email protected]
wrote:

I'm no longer in vacation ;-)

Removed unit test for catching error when a multi-statement SQL string is
handed to db.execute(), since the code halts with a message to the dev in
that case, instead of throwing an error.

I don't get it: executeMultiStatement() throws, and it's good to test that
the thrown error contains all the precious debugging information!

Besides this tiny nitpicking, I can already accept your PR right away.

I would still:

  • Extract UpdateStatement.Changes into DatabaseChanges,
  • Update README.md and RELEASE_NOTES.md

If you still feel inspired, go ahead. I can take it over if you prefer.
You've already done a great job.


Reply to this email directly or view it on GitHub
#6 (comment).

@groue groue merged commit 7d55334 into groue:master Aug 18, 2015
groue added a commit that referenced this pull request Aug 18, 2015
groue added a commit that referenced this pull request Aug 18, 2015
@groue
Copy link
Owner

groue commented Aug 18, 2015

Gorgeous, @peter-ss :-) Thanks a lot!

Do you want write access to the repository?

@groue
Copy link
Owner

groue commented Aug 18, 2015

Version 0.8.0 has just shipped with your contribution.

@peter-ss
Copy link
Contributor Author

Excellent. I'm glad that I was able to contribute.

On Mon, Aug 17, 2015 at 11:25 PM, Gwendal Roué [email protected]
wrote:

Version 0.8.0 has just shipped with your contribution.


Reply to this email directly or view it on GitHub
#6 (comment).

@groue groue changed the title Master Add the ability to execute multiple SQL statements at once Aug 19, 2015
groue added a commit that referenced this pull request Jan 7, 2016
…abase.executeMultiStatement() introduced by #6.
@groue
Copy link
Owner

groue commented Jan 7, 2016

Hello @peter-ss. GRDB v0.37.0 has just shipped, and it has merged your Database.executeMultiStatement() contribution into Database.execute(). You can even feed your multiple statements with arguments, now:

try db.execute(
    "INSERT INTO persons (name) VALUES (?);" +
    "INSERT INTO persons (name) VALUES (?);" +
    "INSERT INTO persons (name) VALUES (?);",
    arguments; ['Harry', 'Ron', 'Hermione'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants