I have a User query which filters by the amount of orders each user has (ordersCount).
User.query.filter('ordersCount>2')
If I run it it says: "Unknown column 'ordersCount' in 'where clause'"
From my experience I should be using having on such operations because mysql won't allow it for fields not part of the table but if I run it with having instead of filter I get:
(1054, "Unknown column 'ordersCount' in 'having clause'") 'SELECT count(1) AS count_1 \nFROM user \nHAVING ordersCount > 2' ()
So how do I filter a count column in sqlalchemy?