Skip to content

Commit

Permalink
fix Expression string casting (#46137)
Browse files Browse the repository at this point in the history
The `Expression` class no longer provides a `__toString()` method, so we cannot cast it to a string here.

We'll now use the `->getValue()` method and pass the current database connection's query grammar.

#44784
  • Loading branch information
browner12 committed Feb 16, 2023
1 parent 3a46fa3 commit 35ce656
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Testing/Constraints/HasInDatabase.php
Expand Up @@ -113,7 +113,7 @@ protected function getAdditionalInfo($table)
public function toString($options = 0): string
{
foreach ($this->data as $key => $data) {
$output[$key] = $data instanceof Expression ? (string) $data : $data;
$output[$key] = $data instanceof Expression ? $data->getValue($this->database->getQueryGrammar()) : $data;
}

return json_encode($output ?? [], $options);
Expand Down

0 comments on commit 35ce656

Please sign in to comment.