diff --git a/src/Exceptions/UnsupportedQueryGrammarException.php b/src/Exceptions/UnsupportedQueryGrammarException.php new file mode 100644 index 0000000..8742100 --- /dev/null +++ b/src/Exceptions/UnsupportedQueryGrammarException.php @@ -0,0 +1,16 @@ +params as $param) { - $params[] = $param->toEloquent(); + $eloquentParam = $param->toEloquent(); + if (is_object($eloquentParam)) { + $grammar = DB::connection()->getQueryGrammar(); + $eloquentParam = $eloquentParam->getValue($grammar); + } + + $params[] = $eloquentParam; } return $this->name . '(' . implode(',', $params) . ')'; diff --git a/src/JsonField.php b/src/JsonField.php index 4b76ce5..16abc06 100644 --- a/src/JsonField.php +++ b/src/JsonField.php @@ -2,10 +2,10 @@ namespace ProcessMaker\Query; -use Exception; use Illuminate\Database\Query\Grammars\MySqlGrammar; use Illuminate\Database\Query\Grammars\SQLiteGrammar; use Illuminate\Support\Facades\DB; +use ProcessMaker\Query\Exceptions\UnsupportedQueryGrammarException; class JsonField extends BaseField { @@ -29,7 +29,7 @@ public function toEloquent($connection = null) } elseif (is_a($grammar, SQLiteGrammar::class)) { return $connection->raw((new \ProcessMaker\Query\Grammars\SQLiteGrammar)->wrapJsonSelector($value)); } else { - throw new Exception('Unsupported query grammar for handling JSON fields.'); + throw new UnsupportedQueryGrammarException(); } } }