fix postgreSQL GROUP BY clause on has filter