tursodatabase / tursodatabase/libsql-client-ts
Allow foreign key constraints to be disabled in batches
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 576
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Description
Our code currently implicitly wraps batches of statements into BEGIN + COMMIT or BEGIN + ROLLBACK. Problem is, in order to temporarily turn off foreign key contraints users might want to send a PRAGMA FOREIGN_KEYS=off statement as a first statement in the batch. Unfortunately, this pragma is not effective inside a transaction: https://www.sqlite.org/foreignkeys.html#fk_enable
A simple workaround would be to check if the first statement happens to be a pragma and execute it outside of the transaction scope. Another simple workaround would be to add a special interface that allows you to say "please run this batch without foreign keys", and then we'd send a PRAGMA FOREIGN_KEYS=off ourselves, right before the BEGIN+COMMIT block.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the batch execution path that currently wraps statements in BEGIN and COMMIT or ROLLBACK. Read the SQLite foreign-key pragma documentation linked in the issue, then determine which proposed interface or transaction-boundary behavior should be implemented; done means batches can disable foreign-key enforcement before the transaction begins.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sqlite, typescript
- Domain
- database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100