-
Notifications
You must be signed in to change notification settings - Fork 61
Description
Setup
I am using usePowerSyncWatchedQuery and have the following watched query that performs a LEFT JOIN across three tables:
- Two normal PowerSync
Tabletables ->listsandtodos - One
LocalOnlytable ->attachments
const todos = usePowerSyncWatchedQuery<TodoEntry>(
`SELECT
todos.id AS todo_id,
todos*,
attachments.id AS attachment_id,
attachments.*
FROM
todos
LEFT JOIN
lists ON todos.list_id = lists.id
LEFT JOIN
attachments ON todos.photo_id = attachments.id
WHERE
todos.list_id = ?`,
[listID],
{ tables: ['todos', 'lists', 'attachments'] }
);
Problem
Without specifying tables in the options payload, the query does not update when making changes to the LocalOnly table attachments.
Solution
As pointed out by @rkistner,
[It] should be fixed in the underlying lib. I assume it's just this bit that doesn't work for local-only tables:
https://github.com/journeyapps/powersync-react-native-sdk/blob/af0031b0eabb4524ad2a507b09487c68d268abb1/packages/powersync-sdk-common/src/client/AbstractPowerSyncDatabase.ts#L404
The solution is to instead use the already defined RegEx, here: https://github.com/journeyapps/powersync-react-native-sdk/blob/af0031b0eabb4524ad2a507b09487c68d268abb1/packages/powersync-sdk-common/src/client/AbstractPowerSyncDatabase.ts#L40