Here's my query, simplified a little (some filters removed):
q = Foo.query.\
join(Foo.bar).\
with_entities(Bar.BAZ, Foo.BAT, ...).\
group_by(Foo.BAT)
This gives me an error:
column "Bar.BAZ" must appear in the GROUP BY clause or be used in an aggregate function
It seems like there are questions on stackoverflow dealing with this error already, like this one, but what they're trying to do is sufficiently dissimilar to what I'm trying to do that I'm having a hard time understanding how their solutions apply and so I think it's alright for me to ask about this error again.
All I want is to group by one of the columns on Foo
. Previously I was doing this in python, but I'd prefer to do it in postgres because I suspect it's faster.