Skip to content

Conversation

@hrach
Copy link
Member

@hrach hrach commented Oct 28, 2024

[closes #666]

@hrach hrach merged commit 6fb9da1 into main Oct 28, 2024
@hrach hrach deleted the fix-duplicated-results-in-aggregation branch October 28, 2024 11:04
@stepapo
Copy link

stepapo commented Oct 30, 2024

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));

@hrach
Copy link
Member Author

hrach commented Oct 30, 2024

@stepapo thx for testcases, did you test them on the #687? Yeah, with #687 I'm thinking about reverting this.

@stepapo
Copy link

stepapo commented Oct 30, 2024

@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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicates in some selections with GROUP+HAVING

3 participants