-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Open
Labels
Description
Laravel Version
11.45.2
PHP Version
8.3
Database Driver & Version
psql (PostgreSQL) 14.10 (Homebrew)
Description
I got the same Problem described in this Issue when I try to use the ?
with joins.
There error is SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "$1"...
It looks like the ?
does not get escape with ??
After some digging i found that for basic where('column', '?', $key)
this was fixed in Illuminate\Database\Query\Grammars\Grammer::295
Possible workarounds that I found were to use the customOperators()
function to add the escaped operators or to write raw queries every time you deal with json columns
Steps To Reproduce
Model::leftJoin('table_2', fn($join) => $join->on(DB::raw("model_table.jsonb->'ids'"),'?','table_2.id'))->get();
The raw query is needed so that the '
not get replaced with ''
and break the query