tursodatabase / tursodatabase/libsql-client-ts

Allow foreign key constraints to be disabled in batches

Open
#173 3 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.