Skip to content
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

Queries impacted by a trigger don't reemit #5326

Open
ursusursus opened this issue Jul 2, 2024 · 0 comments
Open

Queries impacted by a trigger don't reemit #5326

ursusursus opened this issue Jul 2, 2024 · 0 comments
Labels

Comments

@ursusursus
Copy link

ursusursus commented Jul 2, 2024

SQLDelight Version

2.0.2

Application Operating System

Android

Describe the Bug

Hi, I have a multimodule setup.

There is :account module with Account.sq table. Then there is :customer module with Customer.sq table. Customer has a "foreign key" referencing account. (customer is child of account).

Unfortunately due to how build is shaped (monorepo with multiple apps) :customer cannot depend on :account & therefore have a real FOREIGN KEY.

What I do is at app (:app module) I fake the foreign key via triggers (delete from customer when account is deleted + integrity check but that's besides the point now).

CREATE TRIGGER IF NOT EXISTS account_fake_foreign_key_cascade_delete
    BEFORE DELETE ON account
FOR EACH ROW BEGIN
    DELETE FROM user WHERE accountId = old.id;
END;

It works, i.e. when I accountQueries.deleteAccount() and then query customerQueries.customer().executeAsOneOrNull() synchronously it returns null - as expected.

However when I observe customerDao.customer().asFlow().mapToOneOrNull(), it never emits. (the nulll)
(Note that when observing accountQueries.account... it does emit the nulls).

What I think is happening is that the trigger from :app doesn't participate in the notifyQuery codegen.
I think this used to work with 1.x

Stacktrace

No response

@ursusursus ursusursus added the bug label Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant