Skip to content

fix(storage): enforce cache proposal constraints at application level#198

Open
Vswaroop04 wants to merge 1 commit into
BetterDB-inc:masterfrom
Vswaroop04:fix/cache-proposal-sqlite-constraints
Open

fix(storage): enforce cache proposal constraints at application level#198
Vswaroop04 wants to merge 1 commit into
BetterDB-inc:masterfrom
Vswaroop04:fix/cache-proposal-sqlite-constraints

Conversation

@Vswaroop04
Copy link
Copy Markdown
Contributor

@Vswaroop04 Vswaroop04 commented May 14, 2026

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.

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.
@Vswaroop04
Copy link
Copy Markdown
Contributor Author

@KIvanow Can you pls have a look at this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant