-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
sqlite: allow passing conflict resolution handler function #56352
base: main
Are you sure you want to change the base?
Conversation
552a1e8
to
933ce21
Compare
933ce21
to
3635cd9
Compare
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.
Just a couple of quick observations about callback handling.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #56352 +/- ##
========================================
Coverage 88.54% 88.54%
========================================
Files 657 657
Lines 190395 190718 +323
Branches 36552 36603 +51
========================================
+ Hits 168586 168876 +290
- Misses 14992 15010 +18
- Partials 6817 6832 +15
|
f63c3b4
to
a06a068
Compare
src/node_sqlite.cc
Outdated
|
||
if (CreateSQLiteError(isolate, errstr).ToLocal(&e)) { | ||
e->Set(isolate->GetCurrentContext(), | ||
OneByteString(isolate, "errcode"), |
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.
Adding an errcode
similar to CreateSQLiteError(Isolate* isolate, sqlite3* db)
. However, this seems to be an undocumented feature.
@cjihrig Could you run CI? |
Looks like a flaky test. Needs a re-run I think. |
Resolves #56210 by allowing to pass a conflict resolution handler that returns a conflict resolution type instead of just a conflict resolution type.
As @Renegade334 points out in that issue, it does not make sense to pass
SQLITE_CHANGESET_REPLACE
because this conflict resolution type is only valid for certain conflict types. Therefore an API where the conflict-resolution handler receives the conflict type makes sense, so the user can return a valid conflict resolution type for a particular conflict type.An API where an individual (conflicting) change can be inspected (as is possible with the SQLite C conflict handler) would be a good follow-up. This would then be added as a second argument to the conflict handler.
Note that this is a breaking change, but since the SQLite module is experimental I don't think that is an issue.
Note: some of the documentation I added comes pretty much verbatim from the SQLite Documentation, but this is not an issue because the SQLite documentation is dedicated to the public domain. Also I linked to the SQLite documentation.