Replies: 1 comment
-
Originally, because drift was using
Nice idea!
In drift we resolve the issue by looking at triggers and foreign key constraints at build time to build a graph of rules describing which additional tables might be affected by updates.
That's a big advantage for sure. Introducing update notifications as a reliable source and then only relying on the existing mechanism for
Thanks a lot for your interest in making this contribution! This will likely require some architectural changes to the package (that I haven't fully thought through yet). The Another thing to consider is transactions: In drift, a transaction updating a table will directly invalidate query streams made inside of the transaction. Queries created outside of the transaction won't be invalidated if the transaction is rolled back however. And if a transaction makes multiple writes, these are all batched up and delivered in one notification to avoid invalidating streams more than necessary. |
Beta Was this translation helpful? Give feedback.
-
I'm not that familiar with the Drift codebase, but as I understand, Drift currently uses pre-parsing of queries and associated triggers and views to determine which tables could be affected by an insert/update/delete statement.
Is there a reason for not using the native SQLite update notifications for that, as exposed in the updates stream?
My main use case is to be able to use
customStatement
or similar for arbitrary custom queries, and still have watch() on other queries function correctly.At this stage I'm happy to manually pass in tables for the
watch()
query part - I can useEXPLAIN
with the same statement to get the tables it depends on (see this for the implementation).Other advantages of using the updates stream:
At my company we're happy to contribute an implementation of this. But before we start - is this functionality you'll accept as a PR? Are there any major things to take into consideration?
Beta Was this translation helpful? Give feedback.
All reactions