Bind parameters given to Statement#execute persist beyond the call #740
jeremyevans
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I found this behavior surprising. I'm not sure whether it is bug, since there is a simple implementation reason for it, but I don't know whether the behavior is expected or desired. Here's a simple example:
As you can see in the example, if you don't provide a bind parameter to
execute, it uses the last bound value. I believe it works this way becauseexecutecallsbind_paramsif given any parameters, but it does not reset the preexisting bind parameter state after the statement executes.You cannot reset the entire bind parameter state in
execute, because this code is expected to work:My personal expectation would be that parameters given to
executeonly apply to that specific execution and not any subsequent executions. However, I realize that requires an allocation in the case where there are already bound parameters on the statement.Note that this is only an issue when you have multiple
executecalls on the statement, and a bind parameter set by one of the earlierexecutecalls is not set on a later one.All reactions