Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat(sqlite): add preupdate hook #3625
feat(sqlite): add preupdate hook #3625
Changes from 1 commit
7f1fdd9
46df6f8
8da5e6b
3d80e3f
0b6cc5a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
The
sqlite3_value
returned by this call andsqlite3_preupdate_new
has weird semantics. It's a "protected" value so it's thread-safe, but at the same time the documentation also specifies:We should handle this as a
SqliteValueRef
instead, using the same lifetime. The user can then use.to_owned()
to get a fully independent value if they need it.You'll need to add a new case here:
sqlx/sqlx-sqlite/src/value.rs
Line 19 in 1678b19
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.
This should also check
i
againstsqlite3_preupdate_count
because the result is undefined if the index is out of bounds.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.
SqliteValue::new
callssqlite3_value_dup
which creates a copy of thesqlite3_value
. I tested this out by storing the returnedSqliteValue
in a mutex and ensuring the returned value could still be decoded properly after the callback was completed.I can add something to
SqliteValueRef
for this to avoid the call tosqlite3_value_dup
, but I think that would require re-implementing a lot of the logic inSqliteValue
or modifying it so that it can operate on both an owned or borrowed value. Let me know if I'm missing something.EDIT: added this in a separate commit. I can revert it if this isn't what you had in mind.
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.
I think the documentation might be a bit conservative here (or they don't want to make any guarantees) because it does check for these conditions and return an error, but I went ahead and added an explicit check here too.