drizzle-team / drizzle-team/drizzle-orm-docs

useLiveQuery will not detect database deletions using the truncate optimization

Open
#396 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
MDX
Stars
241
Forks
401
Avg merge
5h 44m
Merged PRs (30d)
1

Description

In the documentation for useLiveQuery for expo-sqlite it may be helpful to include a reference to these two cases in which the update hook will not invoked, which means that change listeners will not be notified of changes.

1. "the update hook is not invoked when conflicting rows are deleted because of an [ON CONFLICT REPLACE](https://www.sqlite.org/lang_conflict.html) clause"
2. "Nor is the update hook invoked when rows are deleted using the [truncate optimization](https://www.sqlite.org/lang_delete.html#truncateopt)"

Both above quotes are taken from the [sqlite update_hook documentation.](https://www.sqlite.org/c3ref/update_hook.html)

The truncate optimization can be avoided by adding `.returning()` or `.where()` to the drizzle orm delete statement.

I was trying to figure out why my query results were not changing even when I deleted entire tables from my database, and the truncate optimization was the reason. I'm suggesting that this be included in your documentation because I think it might save other developers debugging time.

If you like this idea, I am happy to draft a PR which adds documentation of this functionality.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.