Laravel update breaks Eloquent queries

Laravel is generally known to be compatible from minor release to minor release, but a recent update breaks many queries and has been reported by several coders!

Some background

For years one has been able to chain “and” in arrays such as:

Object::where([['column','=','value'], ['anothercolumn','=','othervalue']])
->orWhere([['columnB','=','value'],['columnC','=','value']]);

there was an implied “and” within the “orwhere” in cases like this.

Now such query will result in an “OR” and not an “AND” in the inner query. As has been noted in the bug report, one must now change this to:


use Illuminate\Contracts\Database\Eloquent\Builder;

Object::where([['column','=','value'], ['anothercolumn','=','othervalue']])
->orWhere(function(Builder $query) use ($variables) {
	$query->where('frequency','=', $variables)->where('somethingelse', '>', 0);
});

Usually when one does a “composer update” for libraries in a project, you would expect to have the basic query structures be the same, especially for minor upgrades. However in this case the behavior has changed for this “obscure” case. Remember to not just test your site but test various different areas and features and searching on your staging/test area after setting the latest versions!

In other news, the search and states area listing areas are working properly again on hearham.com. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

sixty nine − 63 =