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

Not clearing all bindings #169

Open
zauguin opened this issue Jun 21, 2018 · 2 comments
Open

Not clearing all bindings #169

zauguin opened this issue Jun 21, 2018 · 2 comments

Comments

@zauguin
Copy link
Collaborator

zauguin commented Jun 21, 2018

Often we need a statement where only some bound parameters change with every use.
Currently we clear bindings every time we reset the bindings so we have to bind all parameters again after every usage.
This gets complicated if you want to pass the prepared statement to another function without all the parameters you want to use every time.

Maybe we could make clearing the bindings optional? Or does anyone has an idea for a nice interface which allows reusing the bindings?

I thought about adding a method .fix_parameters(n) which indicates to no longer modify/clear the first n parameters. There is no sqlite3 function for clearing a subset of all bound parameters, but we could probably emulate this.

@aminroosta
Copy link
Collaborator

@zauguin according to documentation sqlite3_reset does not rest the bindings.
The reason we are calling sqlite3_clear_bindings here.

I wonder what happens if we don't clear the previous bindings and just bind again to an already bound parameter?

Is is ok to use sqlite3_bind_* on the same parameter index without clearing the existing bindings?

@zauguin
Copy link
Collaborator Author

zauguin commented Jun 21, 2018

It is OK to rebind without clearing first. The only problem with it is that it can be confusing for your old bindings to still have an effect after calling reset.

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

No branches or pull requests

2 participants