Skip to content

Conversation

@aminroosta
Copy link
Collaborator

… scope

@Killili
Copy link
Collaborator

Killili commented Mar 5, 2016

I think i did that on purpose so until i remember why we should run with it.

@aminroosta
Copy link
Collaborator Author

Sure, No problem :-)
Although what @mqudsi described in #34 looks like a bug.

@Killili
Copy link
Collaborator

Killili commented Mar 5, 2016

Nope its even documented behavior ;)

@aminroosta
Copy link
Collaborator Author

@Killili
You are right, Although its not that clear in the docs :)
But i think it means that users should manually set ps.used(true).

// If you dont need the returned values you can execute it like this
ps.execute(); // the statement will not be reset!
// To disable the execution of a statment when it goes out of scope and wasn't used
ps.used(true); // or false if you want it to execute even if it was used

Is there a good reason not to set ps.used(true) at the end of ps.execute() call?
I don't see why this can not be the default behavior.

@mqudsi
Copy link
Contributor

mqudsi commented Mar 5, 2016

@Killili I don't think it's documented that way.
What the documentation says:

    // If you dont need the returned values you can execute it like this
    ps.execute(); // the statment will not be reset!

"Will not be reset" doesn't (to me) directly imply "will still be executed", as "reset" is mentioned in the docs as:

    // after a successfull execution the statment needs to be reset to be execute again. This will reset the bound values too!
    ps.reset();

That aside, the docs say "If the statment was executed once it will not be executed again when it goes out of scope." Calling statement->execute() would heavily imply (some would say, definitively so) that the statement was, well, executed. ;-)

@aminroosta
Copy link
Collaborator Author

@mqudsi I agree, that's why i think it should be the default behavior.
I want @Killili to take another look at the diff.
I am also setting ps.used(false) on ps.reset() call. which should be fine.
but i want to make sure. :-)

Killili added a commit that referenced this pull request Mar 5, 2016
prevent prepared- statements from executing again when they go out of…
@Killili Killili merged commit d16849d into master Mar 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants