fix(storage): enforce cache proposal constraints at application level#198
Open
Vswaroop04 wants to merge 1 commit into
Open
fix(storage): enforce cache proposal constraints at application level#198Vswaroop04 wants to merge 1 commit into
Vswaroop04 wants to merge 1 commit into
Conversation
Expression-based partial unique indexes are silently skipped on some SQLite builds in CI, leaving the constraints unenforced. Mirror the CHECK and UNIQUE constraints in createCacheProposal so the behaviour is consistent regardless of SQLite version.
Contributor
Author
|
@KIvanow Can you pls have a look at this PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
SQLite on the Linux CI build silently skips the expression-based partial unique indexes used for the cache proposal constraints (COALESCE(json_extract(...))). Because of that, the UNIQUE and CHECK constraints are not actually enforced at the database level in CI, which causes the failing cache-proposals-sqlite.spec.ts tests.
This change adds matching validation inside createCacheProposal so the behaviour stays consistent even when SQLite does not create those indexes correctly. The validation mirrors the intended database constraints and prevents duplicate pending proposals from being created.
Some existing PR test runs are currently failing because of this issue as well, so getting this merged should stabilise those SQLite CI failures.
One thing I wanted to clarify with maintainers (@KIvanow , @jamby77) : should duplicate pending proposals ever be allowed as a fallback when SQLite skips the expression index, or is strict enforcement the intended behaviour across all environments?
Also verified that proposals for different categories are still allowed correctly.