Skip to content

Commit d2dec15

Browse files
committed
Ensure $casts are obeyed for where query building
1 parent 5ea2a83 commit d2dec15

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Jenssegers/Mongodb/Query/Builder.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,22 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
875875
}
876876
}
877877

878+
// Convert $casts
879+
if($this->isCastableToObjectId($column))
880+
{
881+
if(is_array($params[2])) {
882+
foreach ($params[2] as &$value) {
883+
if(is_string($value)) {
884+
$value = new ObjectId($value);
885+
}
886+
}
887+
} else {
888+
if(is_string($params[2])) {
889+
$params[2] = new ObjectId($params[2]);
890+
}
891+
}
892+
}
893+
878894
return call_user_func_array('parent::where', $params);
879895
}
880896

0 commit comments

Comments
 (0)