unselected attribute used in relationship filter + aggregate results in column does not exist error
I'm not sure at what level of the stack this bug is happening, but I suspect it's at the ash_sql level.
I have an ltree based resource. I decided to use relationships/calculations to abstract some of the ltree details away, so I have a
children relationship that looks like this (level is the ltree column, and nlevel is a calculation that is just nlevel(level)):
I then have this aggregate:
Using ash_graphql, I grab some resources like this (note I do not select level):
This results in the following error from postgres:
** (Postgrex.Error) ERROR 42703 (undefined_column) column s0.level does not exist
It seems like at some point, ash loses track of the fact it needs to include the level field in the SQL select so that it can correlate the relationship to it, even though it doesn't need to be included in the gql response.8 Replies
This is what the generated SQL looks like (formatted), for reference:
Solution
There is an open bug about this in ash_postgres
Hopefully will be fixed soon
Oh nice! Luckily for the time being I can make do with just having the graphql select
level. Glad to hear it's at least known ❤️ thanks!ah looks like this one? https://github.com/ash-project/ash_postgres/pull/644
GitHub
Add failing test for aggregate with parent() + select() + limit() b...
Reproduces a bug where combining select() + limit() with an aggregate that uses parent() in its filter causes SQL error.
This bug was found in ash_graphql where GraphQL list queries would automatic...
Yep!
I'll try to get more work done on the ash_sql pr this week, I'm at codebeam though, so no promises 🙂
I actually have some work going on it
its very hard lol