Skip to content

Commit 9ada6c7

Browse files
committed
fix filter matching for variants
1 parent 7063484 commit 9ada6c7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/Driver/Mysqli/Mysqli.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ public function query(Query $query): QueryResult
248248
/** @var class-string<ModelInterface> $modelClass */
249249
$modelClass = $query->modelClassName;
250250
$model = $modelClass::getModelFromData($row);
251-
$result->add($model);
251+
if ($model) {
252+
$result->add($model);
253+
}
252254
}
253255

254256
return $result;

src/GenericModel.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,17 @@ public static function matchesFilters(array $rawData): bool
250250
return true;
251251
}
252252
foreach (static::$filters as $key => $value) {
253-
if (!isset($rawData[$key]) || $rawData[$key] !== $value) {
253+
if (!isset($rawData[$key])) {
254+
return false;
255+
}
256+
$dataValue = $rawData[$key];
257+
if (is_int($value) && !is_int($dataValue)) {
258+
$dataValue = (int)$dataValue;
259+
} elseif (is_float($value) && !is_float($dataValue)) {
260+
$dataValue = (float)$dataValue;
261+
}
262+
263+
if ($value !== $dataValue) {
254264
return false;
255265
}
256266
}

0 commit comments

Comments
 (0)