framework icon indicating copy to clipboard operation
framework copied to clipboard

Database query count returns incorrect count with distinct

Open Jnesselr opened this issue 11 years ago • 5 comments

When using the query builder, it's possible that $query->count() == count($query->get()) is false when the distinct method is thrown into the mix.

I wrote a test query that without the distinct returned 6 rows, but with it returned 3. However, the count method on the builder still returned 6 even though the count function correctly said it was 3.

This was with a sqlite database.

Jnesselr avatar Sep 12 '15 11:09 Jnesselr

What Laravel version please?

GrahamCampbell avatar Sep 12 '15 19:09 GrahamCampbell

ah, sorry, thought I put that. 5.1, tested on a fresh install.

Jnesselr avatar Sep 12 '15 19:09 Jnesselr

Can you please provide a code sample in gist? I can't seem to reproduce exactly what is happening for you, but I'm assuming that I misunderstood the implementation in my local test.

scrothers avatar Sep 15 '15 04:09 scrothers

Could it be somehow connected to #9385 and #9528

loginwashere avatar Sep 25 '15 09:09 loginwashere

Probably. I think we had to revert some of that, and marked this as a nofix.

GrahamCampbell avatar Sep 25 '15 10:09 GrahamCampbell