Skip to content

Commit d3ba7b5

Browse files
author
Max Shaian
committed
v0.4.0
1 parent 7124bb1 commit d3ba7b5

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Engines/CollectionMeiliSearchTestEngine.php

+5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function isFound(ScoutBuilder $builder, $model): bool
5454
}
5555

5656
$searchable = $model->toSearchableArray();
57+
$searchable[$model->getKeyName()] = $model->getKey();
5758

5859
if (count($builder->wheres)) {
5960
if (!$this->checkConditions($builder->wheres, $searchable)) {
@@ -170,6 +171,10 @@ protected function checkQuery(ScoutBuilder $builder)
170171
continue;
171172
}
172173

174+
if ($where->field === $builder->model->getKeyName()) {
175+
continue;
176+
}
177+
173178
$wheres[] = $where->field;
174179
}
175180

tests/Feature/CollectionDriverTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ public function test_filters()
116116
'field_d' => null,
117117
'field_e' => [5, 6, 7],
118118
]);
119+
120+
$mock
121+
->shouldReceive('getKeyName')
122+
->andReturn('primary_key_name');
123+
124+
$mock
125+
->shouldReceive('getKey')
126+
->andReturn(22);
119127
});
120128

121129
$builder = new Builder($model, '');
@@ -191,5 +199,9 @@ public function test_filters()
191199
$builder->wheres = [];
192200
$builder->where('field_e', 8);
193201
$this->assertFalse($engine->isFound($builder, $model));
202+
203+
$builder->wheres = [];
204+
$builder->where('primary_key_name', 22);
205+
$this->assertTrue($engine->isFound($builder, $model));
194206
}
195207
}

0 commit comments

Comments
 (0)