-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
watch steam just fake death after get empty dataset #3406
Comments
That's definitely not the expected behavior, drift should keep on listening until you cancel the subscription. Could you also show how you're listening to the stream? |
thanks for your reply @simolus3 , here is my test code:
the test keep running forever. and the log sample like this:
I just received 6 billLogs, the expected is 12. In the last part of the log, I checked the billLog table, it contains the remaining 6 billLogs, but didn't get it from the stream. If I remove the If more information is needed, please let me know |
FYI, the issue seems related to the trigger, the test above inserts bill data, and the trigger inserts bill_log data. I changed the test to insert bill_log directly, and the test also passed:
|
Sorry for the slow response. Could you share how you're defining the trigger? Drift needs information about how changes in one table might affect rows in another table. If you define triggers in a drift file that's no problem, but if you add the trigger manually with a |
sure. I define the trigger in database class, override the migration and define the trigger in the onCrete param:
|
You can add the following override to your database class to fix this. It tells drift that changes to the @override
StreamQueryUpdateRules get streamUpdateRules => StreamQueryUpdateRules([
...super.streamUpdateRules.rules,
WritePropagation(
on: TableUpdateQuery.onTableName('bills'),
result: [
TableUpdate('bill_logs', kind: UpdateKind.insert),
],
),
]); |
It works well, thanks a lot! Since I am still unfamiliar with streamUpdateRules, I don't find many docs about it. even in the drift doc site: https://drift.simonbinder.eu/. could you please give me more information or references about streamUpdateRules, thanks. |
These aren't mentioned on the documentation site because they're not typically relevant to most users. You can read more on the dart API docs, although I admit they're a bit sparse. Let me know if you're interested about something specifically. The basic idea is that drift implements stream queries by:
This only works when all affected writes are known to drift, but triggers change tables on a lower level. So drift needs to know about how updates to one table ( |
Hi diift teams.
I have a trigger to record a bill update, it will write data to bill_log. And watch the bill_log, then process it and delete the bill_log record.
the watch stream just fake death once it gets empty bill_log, it never get any more bill_log. the stream neither call done or error.
the code sample likes this:
or this:
version:
drift: ^2.21.0
drift_flutter: ^0.2.1
thanks
The text was updated successfully, but these errors were encountered: