Not sure what the problem is. The limit 1 is probably to save memory usage.
It is okay to limit the sql statement for the existence check but it is not okay that it also affects the resultset which i want to get.
$faa = User::where("foo",'"=","faa");
if($faa->exists()) { -> select count(*) as aggregate from "user" where "user"."foo" like 'faa' limit 1
echo $faa[0]->name; // For whatever reason, it is just pseudo code
foreach($faa->get() as $elem) -> `select * from "user" where "user"."foo" = 'faa' limit 1 <-- and that is not what i am expecting
{
dosomething()
}
As soon i check for existence he limits the sql statement to 1. If i comment out the existence check i get the whole resultset. However if i dont check for existence and there is no result returned i would get a "Trying to access a property of a non-object" exception. I dont think this should be the normal behaviour but actually that is what get deployed on the 4.2.13 patch.
IMO that feels like a bug. An existence check on a model should not modify the model.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community