-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Bug Report
| Q | A |
|---|---|
| Version | 4.3.1 |
| Previous Version if the bug is a regression | no regression |
Summary
In PostgreSQL, the following is a valid statement (that should return true):
SELECT '["foo", "bar"]'::jsonb ? 'foo'See PostgreSQL documentation on JSON operators for details of the ? operator (and the equivalently problematic ?|).
Current behavior
When used in a prepared statement, Doctrine DBAL interprets the operator as denoting a positional parameter. It thus replaces it with $1 (in the above query, number might differ in other queries), which PostgreSQL then complains about, because it requires an operator at that position:
Uncaught Doctrine\DBAL\Driver\PgSQL\Exception: syntax error at or near "$1" in vendor/doctrine/dbal/src/Driver/PgSQL/Exception.php:25
In some other constellation, I had the following exception instead:
Uncaught Doctrine\DBAL\ArrayParameters\Exception\MissingPositionalParameter: Positional parameter at index 0 does not have a bound value.
Expected behavior
Doctrine detects that this isn't a positional parameter and forwards the ? unmodified
How to reproduce
$conn->prepare('SELECT \'["foo", "bar"]\'::jsonb ? \'foo\'');