Filtering by/selecting calculations when working with direct ecto queries

I have a use case where I'm needing to reach for Ecto directly. I'm trying to see if it's possible to filter by a calculation (or even just select it) when doing this. I can of course duplicate my calculation logic, but looking for a way to avoid that if possible 😅
Solution:
Nope 😄
Jump to solution
5 Replies
Solution
ZachDaniel
ZachDaniel•2w ago
Nope 😄
ZachDaniel
ZachDaniel•2w ago
I mean, kind of Its not fun to make happen though
Jesse Williams
Jesse WilliamsOP•2w ago
gotcha Probably not worth it in my use case I'm gonna assume 😅
ZachDaniel
ZachDaniel•2w ago
You could potentially get them selected and then subquery and then filter on them for example Probably not, but it depends on how horrible it would be without it 😆
Jesse Williams
Jesse WilliamsOP•2w ago
Not really all that bad, just felt like the sort of thing I had to at least attempt before just duplicating code 😅

Did you find this page helpful?