-
Notifications
You must be signed in to change notification settings - Fork 12
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 support for prepared statements #13
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you.
Could you write a test for what happens when the connection has been closed and then the statement is run. Thank you
Thank you very much for the code review. I wrote some tests and got inconsistent results depending on the target platform. 1. Running a normal
|
Hello, I used this version in a private project of mine, and tests failed. After a few hours of debugging, I found the problem. If you don't reset the prepared statement after an error occurs, this error will reappear when the prepared statement is used again. This is now solved, and I added the test case which triggered this bug by not resetting the prepared statement after each use. I also set a flag to indicate that these prepared statements are persistent. Thank you very much! :) |
Hello :)
I added support for prepared query statements to improve overall performance when queries are reused.
Since both libraries (Erlang and JavaScript) use prepared statements under the hood when calling
query
, I split this function intoprepare
andquery_prepared
.I also updated every test that uses
sqlight.query
by introducing a helper function that ensures both functions return the same errors and results.I had to wrap the database connection in
sqlight_ffi.js
to keep track of the created prepared statements since the library requires that they be finalized before closing the connection. I think this isn't the most elegant solution, but I'm not aware of a better approach.I also updated the
README
example, theCHANGELOG
, and bumped the version to0.10.0
.Thank you very much for the great work, and I'm hoping I didn't miss anything this time. :)