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

sqlite: allow passing conflict resolution handler function #56352

Merged
merged 12 commits into from
Dec 29, 2024

Conversation

louwers
Copy link
Contributor

@louwers louwers commented Dec 24, 2024

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.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. labels Dec 24, 2024
@louwers louwers force-pushed the sqlite-conflict-handler branch 4 times, most recently from 552a1e8 to 933ce21 Compare December 24, 2024 16:11
@louwers louwers force-pushed the sqlite-conflict-handler branch from 933ce21 to 3635cd9 Compare December 24, 2024 16:11
@louwers louwers changed the title sqlite: pass conflict type to conflict-resulution handler sqlite: pass conflict type to conflict resolution handler Dec 24, 2024
Copy link
Contributor

@Renegade334 Renegade334 left a 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.

src/node_sqlite.cc Outdated Show resolved Hide resolved
src/node_sqlite.cc Outdated Show resolved Hide resolved
Copy link

codecov bot commented Dec 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.54%. Comparing base (4fd5db4) to head (5e39d22).
Report is 32 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #56352    +/-   ##
========================================
  Coverage   88.54%   88.54%            
========================================
  Files         657      657            
  Lines      190395   190718   +323     
  Branches    36552    36601    +49     
========================================
+ Hits       168586   168877   +291     
- Misses      14992    15021    +29     
- Partials     6817     6820     +3     
Files with missing lines Coverage Δ
src/node_sqlite.cc 82.34% <100.00%> (+0.54%) ⬆️

... and 41 files with indirect coverage changes

@louwers louwers force-pushed the sqlite-conflict-handler branch from f63c3b4 to a06a068 Compare December 24, 2024 20:58
src/node_sqlite.cc Outdated Show resolved Hide resolved
@louwers
Copy link
Contributor Author

louwers commented Dec 24, 2024

@cjihrig Could you run CI?

@cjihrig cjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 24, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 24, 2024
@nodejs-github-bot
Copy link
Collaborator

@louwers louwers changed the title sqlite: pass conflict type to conflict resolution handler sqlite: allow passing conflict resolution handler function Dec 24, 2024
@louwers louwers requested a review from Renegade334 December 25, 2024 19:38
@louwers
Copy link
Contributor Author

louwers commented Dec 25, 2024

Looks like a flaky test. Needs a re-run I think.

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

src/node_sqlite.cc Outdated Show resolved Hide resolved
doc/api/sqlite.md Outdated Show resolved Hide resolved
src/node_sqlite.cc Outdated Show resolved Hide resolved
src/node_sqlite.cc Outdated Show resolved Hide resolved
@louwers
Copy link
Contributor Author

louwers commented Dec 28, 2024

@cjihrig Thanks for the review. Could you trigger another CI run?

@cjihrig cjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 29, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 29, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@cjihrig cjihrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. commit-queue Add this label to land a pull request using GitHub Actions. and removed needs-ci PRs that need a full CI run. labels Dec 29, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 29, 2024
@nodejs-github-bot nodejs-github-bot merged commit 0dbbaba into nodejs:main Dec 29, 2024
69 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 0dbbaba

aduh95 pushed a commit that referenced this pull request Jan 2, 2025
PR-URL: #56352
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. sqlite Issues and PRs related to the SQLite subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sqlite: Exceptions on conflict handling with database.applyChangeset()
5 participants