Upgrade from 3.5.12 to 3.7.6 Broke Calculcation

I'm getting this strange error suddenly:

Unknown Error

* ** (MatchError) no match of right hand side value: {:error, "Invalid reference project.client.project.currency"}

Unknown Error

* ** (MatchError) no match of right hand side value: {:error, "Invalid reference project.client.project.currency"}
I have a calcluation that dispalyed a rate and price with currency like here;
calculations do
calculate :currency, Plangora.Projects.Currency, expr(project.currency)
calculate :rate_with_currency, :string, expr(service.rate <> " " <> project.currency)
end
calculations do
calculate :currency, Plangora.Projects.Currency, expr(project.currency)
calculate :rate_with_currency, :string, expr(service.rate <> " " <> project.currency)
end
And this seems to be breaking when I load the calcluation.
16 Replies
sevenseacat
sevenseacat•2mo ago
where does client come into things? what resource is this?
allenwyma
allenwymaOP•2mo ago
thanks, i suppose i need to layout my diagram: TimeEntry -> belongs to Service, Project, User attributes: rate, hours Project -> Belongs to Client I'm showing all time entries with the rate and total across all projects for all users: So i would believe that the time entry -> project -> client ##> currency As each client has a different currency
ZachDaniel
ZachDaniel•2mo ago
Will need a repro for this one. We fixed the way that nested calculation exists work, and must have had an unintended consequence We need whatever you're doing as a test case 😅
allenwyma
allenwymaOP•2mo ago
sure should i just make a reproduction repo? can work on that, today, as i'd like to update this project to add more features 😄
ZachDaniel
ZachDaniel•2mo ago
It's up to you. I make no guarantees as to when I will look at it, but can only offer the fact that if you make a PR with a test failure I will be significantly more likely to look into it **sooner
allenwyma
allenwymaOP•2mo ago
Yeah. I will do that today. Fastest is I just reproduce my issue in a separate repo after looking further, it seems to be this:
aggregates do
first :currency, [:assignment, :project, :client], :currency
end
aggregates do
first :currency, [:assignment, :project, :client], :currency
end
* ** (MatchError) no match of right hand side value: {:error, "Invalid reference project.client.project.currency"} changing to calculation seems to work:
calculate :currency, :atom, expr(assignment.project.client.currency), public?: true
calculate :currency, :atom, expr(assignment.project.client.currency), public?: true
ZachDaniel
ZachDaniel•2mo ago
🤔 very strange
allenwyma
allenwymaOP•2mo ago
indeed. it works after changing to calculation 😄
kernel
kernel•5w ago
I think it's affected me also 🤣 , that silly policy I have is now failing (policy checking relates_to_actor_via a no_attributes has_many relationship which references a calculation which references a list aggregate) (the ST_Union() etc etc)
ZachDaniel
ZachDaniel•5w ago
@allenwyma I fixed something related to this in Ash core that may have helped here? not sure. It fixed something WRT nested calculations accessed on relationships, so its at least tangentially related
allenwyma
allenwymaOP•5w ago
thanks! you want me to revert and try? i just changed to the above style to fix it since it's basically the same
ZachDaniel
ZachDaniel•4w ago
If you could yes. Also is there a big open for the issue right now? If not, and it's still broken, please open one
allenwyma
allenwymaOP•4w ago
i need to check this still, but haven't had a moment. sorry
Meeq
Meeq•2w ago
I am also experiencing breakage with calculations, specifically with these versions (they all get upgraded together):
ash 3.6.3 => 3.7.0
ash_authentication 4.11.0 => 4.12.0
ash_postgres 2.6.22 => 2.6.23
ash_sql 0.3.6 => 0.3.12
ash 3.6.3 => 3.7.0
ash_authentication 4.11.0 => 4.12.0
ash_postgres 2.6.22 => 2.6.23
ash_sql 0.3.6 => 0.3.12
I think it's because I'm combining expr with load in the calculate definition, as this PR would indicate. Hmmm. There's still something wrong; the symptom I'm seeing is that Cinder is not loading my calculations when Ash >= 3.7.0 I'm narrowing it down to loading calculations + aggregates together This issue is harder to nail down than I thought it would be. Claude has failed me for creating an isolated test case.
Meeq
Meeq•2w ago
Oh, man. I just spent hours reproducing this only to discover that there's already an issue for it on ash_sql: https://github.com/ash-project/ash_sql/issues/190
GitHub
Ecto.QueryError: when loading aggregates in the query with Ash.Quer...
Code of Conduct I agree to follow this project&#39;s Code of Conduct AI Policy I agree to follow this project&#39;s AI Policy, or I agree that AI was not used while creating this issue. Versions El...
Meeq
Meeq•2w ago
I found another bug, so it wasn't a total waste of time: https://github.com/ash-project/ash_sql/issues/191
GitHub
Calculations fail to load when loading aggregate · Issue #191 · a...
Code of Conduct I agree to follow this project&#39;s Code of Conduct AI Policy I agree to follow this project&#39;s AI Policy, or I agree that AI was not used while creating this issue. Versions as...

Did you find this page helpful?