-
Notifications
You must be signed in to change notification settings - Fork 354
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 to emit deletion by cascade? #726
Comments
If you define the foreign key constraint in a moor file, that should be reflected in the generated code. The generated database should override |
Well... I haven't found a |
Ah - right. The You could also add the override manually. So if you had a table @UseMoor(...)
class Database extends _$Database {
StreamQueryUpdateRules get streamUpdateRules {
return StreamQueryUpdateRules([
WritePropagation(
on: TableUpdateQuery.onTable(foots, limitUpdateKind: UpdateKind.delete),
result: [
TableUpdate.onTable(bars, kind: UpdateKind.delete),
],
),
]);
}
} |
@simolus3 Well it is working. Thank you very much. |
@perojas3 - thanks for jumping in and clarify!
Now, let's have a look at the
Hopefully, so far both - tables and AppDatabase classes are correctly updated - let me know if they are. |
The snippet you posted is correct, yes. It basically tells moor that deleting a person might delete an activity as well. Might want to add an
You already did in your snippet 😉 If your IDE complains about |
@simolus3 - I see, basically, the snippet added to the |
@simolus3 - and while we are still on the topic, what should |
Yes. Let me know if that doesn't work for you.
You only need to include the direct effects, moor will crawl the rules to respect transitive effects as well. So it could look like return StreamQueryUpdateRules([
WritePropagation(
on: TableUpdateQuery.onTable(persons, limitUpdateKind: UpdateKind.delete),
result: [
TableUpdate.onTable(activities, kind: UpdateKind.delete),
],
),
WritePropagation(
on: TableUpdateQuery.onTable(activities, limitUpdateKind: UpdateKind.delete),
result: [
TableUpdate.onTable(item, kind: UpdateKind.delete),
],
),
]); |
How is this resolved in Drift 2.1.0? This issue still persists. |
@karlopenguini Does the generated file drift gives you have a |
|
So I am using watch to create a stream that show the changes in the database.
Also used foreign keys with delete cascade, so every time I delete an entity, other ones are deleted too.
Can I do the same at once? Deleting with cascade and automatically shown in the stream?
In android's room that can be done, but with moor I tried some tests and no the stream didn't emitted the changed, even though the database made the change.
But the problem could be mine.
It can be done?
The text was updated successfully, but these errors were encountered: