-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
Computed fields on related table are not recalculated when returned in mutation data. #337
Comments
Hi @ncrmro, Computed field functions written in SQL should be marked volatile to avoid stale results from mutations. This is a direct consequence of Postgres volatility category behaviour. Quoting from the docs:
I have updated the docs in #443 with this suggestion. In other words, to fix stale results, change your function to this: CREATE OR REPLACE FUNCTION _count(rec parent)
RETURNS smallint
VOLATILE
LANGUAGE sql
AS
$$
SELECT SUM(count)
FROM child
WHERE parent_id = rec.id
$$; |
add test case and docs for issue #337
Describe the bug
I have two tables linked by a foreign key the parent has a computed field, when performing a mutation the parent computed columns return their original values rather than the value post mutation.
I have confirmed the row is updated on refresh web page or when querying the database directly.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expect the related fields computed column to correctly return an updated value.
Screenshots
If applicable, add screenshots to help explain your problem.
Versions:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: