Skip to content

Commit 238d9b2

Browse files
committed
moved the stripping of empty find requests to the FileMaker connection, right before we decide which endpoint to hit
1 parent c806cfa commit 238d9b2

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/Database/Eloquent/FMEloquentBuilder.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,16 +296,6 @@ public function applyScopes()
296296
{
297297
$builder = parent::applyScopes();
298298

299-
$query = $builder->getQuery();
300-
301-
foreach ($query->wheres as $index => $find) {
302-
if (! empty($find)) {
303-
continue;
304-
}
305-
306-
unset($query->wheres[$index]);
307-
}
308-
309299
return $builder;
310300
}
311301

src/Services/FileMakerConnection.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ public function performFind(FMBaseBuilder $query)
254254
$query->limit = self::CRAZY_RECORDS_AMOUNT;
255255
}
256256

257+
// remove any empty arrays from wheres
258+
// an empty find is invalid
259+
$query->wheres = collect($query->wheres)->filter(function ($item) {
260+
return is_array($item) ? count($item) > 0 : true;
261+
})->toArray();
262+
257263
// if there are no query parameters we need to do a get all records instead of a find
258264
if (empty($query->wheres) && ! $query->isForcingHighOffset()) {
259265
return $this->getRecords($query);
@@ -511,7 +517,7 @@ public function buildPostDataFromQuery(FMBaseBuilder $query)
511517
foreach ($params as $attribute => $request) {
512518
$value = $query->$attribute;
513519

514-
// just skip everything else if the value is null
520+
// just skip everything else if the value is null
515521
if ($value === null) {
516522
continue;
517523
}

0 commit comments

Comments
 (0)