Closed hrach closed 1 month ago
I am a bit confused with separate WHERE and HAVING in some cases. For example these two produce identical query, which can't be right, as it only works with AND.
$this->model->books->findBy([
ICollection::OR,
['title' => 'Book 1'],
[CompareGreaterThanFunction::class, [CountAggregateFunction::class, 'tags->id'], 0],
]);
$this->model->books->findBy([
ICollection::AND,
['title' => 'Book 1'],
[CompareGreaterThanFunction::class, [CountAggregateFunction::class, 'tags->id'], 0],
]);
SELECT "books".* FROM "books" AS "books"
LEFT JOIN "books_x_tags" AS "books_x_tags__COUNT" ON ("books"."id" = "books_x_tags__COUNT"."book_id")
LEFT JOIN "tags" AS "tags__COUNT" ON ("books_x_tags__COUNT"."tag_id" = "tags__COUNT"."id")
WHERE ((("books"."title" = 'Book 1')))
GROUP BY "books"."id", "books"."title"
HAVING ((COUNT("tags__COUNT"."id") > 0));
@stepapo thx for testcases, did you test them on the #687? Yeah, with #687 I'm thinking about reverting this.
@stepapo thx for testcases, did you test them on the #687? Yeah, with #687 I'm thinking about reverting this.
Yes I tested them on #687 .
[closes #666]