Skip to content

Commit

Permalink
cast Expression as string so it can be encoded (#34569)
Browse files Browse the repository at this point in the history
because the `Expression` contains no public properties, when it is JSON encoded, it will always return '{}', which is unhelpful to us in debugging.
  • Loading branch information
browner12 committed Sep 28, 2020
1 parent 5621b67 commit 7ff9a2d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Constraints/HasInDatabase.php
Expand Up @@ -111,6 +111,10 @@ protected function getAdditionalInfo($table)
*/
public function toString($options = 0): string
{
return json_encode($this->data, $options);
foreach ($this->data as $key => $data) {
$output[$key] = $data instanceof Expression ? (string) $data : $data;
}

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

0 comments on commit 7ff9a2d

Please sign in to comment.