From b6eed375e898217c0e0ee01a996507e2bcc39b91 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Fri, 12 Jul 2024 19:23:22 +0700 Subject: [PATCH] Fix possible bag when using join another table --- src/ActiveRelationTrait.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ActiveRelationTrait.php b/src/ActiveRelationTrait.php index 5febf3392..275d9d6cd 100644 --- a/src/ActiveRelationTrait.php +++ b/src/ActiveRelationTrait.php @@ -24,6 +24,7 @@ use function array_filter; use function array_flip; use function array_intersect_key; +use function array_key_first; use function array_keys; use function array_merge; use function array_unique; @@ -551,8 +552,9 @@ protected function filterByModels(array $models): void $values = [...$scalarValues, ...$nonScalarValues]; $attribute = reset($attributes); + $columnName = array_key_first($this->link); - match ($this->getARInstance()->columnType($attribute)) { + match ($this->getARInstance()->columnType($columnName)) { 'array' => $this->andWhere(new ArrayOverlapsCondition($attribute, $values)), SchemaInterface::TYPE_JSON => $this->andWhere(new JsonOverlapsCondition($attribute, $values)), default => $this->andWhere(new InCondition($attribute, 'IN', $values)),