Closed
Description
Eloquent count() completely ignores what is in select and just adds count(*) as aggregate into select part. If get() method generates this query :
select sellers.* from sellers
left join locations
on locations.seller_id = sellers.id
group by sellers.id
count() would generate this :
select count(*) as aggregate from sellers
left join locations
on locations.seller_id = sellers.id
group by sellers.id
but what should really generate is this :
SELECT count(*) FROM (
select sellers.* from sellers
left join locations
on locations.seller_id = sellers.id
group by sellers.id) as aggregate ;
If we have 2 sellers the :
The first query generated from count() call returns result 1, but there are 2 sellers.
The second query returns 2 as it should.
Metadata
Metadata
Assignees
Labels
No labels