php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80311 jsonb operators not supported
Submitted: 2020-11-03 14:06 UTC Modified: 2020-11-03 14:20 UTC
Votes:5
Avg. Score:4.0 ± 1.5
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:2 (50.0%)
From: boan at jfmedier dot dk Assigned:
Status: Verified Package: PDO PgSQL
PHP Version: 7.2.34 OS:
Private report: No CVE-ID: None
 [2020-11-03 14:06 UTC] boan at jfmedier dot dk
Description:
------------
When trying to query a jsonb field in postgresql with the questionmark operator, we get error code 42601.

`$pdo->query("SELECT * FROM term_template tt WHERE (sites->0) ? 'site_id'");`

`"ERROR:  syntax error at or near "$1"
LINE 1: SELECT * FROM term_template tt WHERE (sites->0) $1 'site_id'..."`

See jsonb operators here: 

https://www.postgresql.org/docs/10/functions-json.html

The query works when executed within a database tool.

Test script:
---------------
Fixture data in DB "sites" column:

[{"site_id": "example.org"}]




Patches

lxbfYeaa (last revision 2024-04-15 15:40 UTC by testing at example dot com)
LmMqtzme (last revision 2024-04-11 21:20 UTC by testing at example dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-03 14:20 UTC] cmb@php.net
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2020-11-03 14:20 UTC] cmb@php.net
This is expected behavior, because the question mark is considered
to be a placeholder.  As of PHP 7.4.0, it is possible to escape
the question mark by doubling it[1].

Changing this to doc problem, since apparently that escaping
mechanism is not yet documented in the manual proper[2].

[1] <https://www.php.net/manual/en/migration74.new-features.php#migration74.new-features.pdo>
[2] <https://www.php.net/manual/en/pdo.prepared-statements.php>
 [2022-12-27 06:12 UTC] alisausxbpn53 at gmail dot com
Thanks for that. 

(https://www.telltims.org/)github.com
 [2022-12-31 06:33 UTC] alisauxbpddn53 at gmail dot com
Thanks for that. (https://www.telltims.net/)github.com
 [2024-04-11 21:20 UTC] testing at example dot com
The following patch has been added/updated:

Patch Name: LmMqtzme
Revision:   1712870458
URL:        https://bugs.php.net/patch-display.php?bug=80311&patch=LmMqtzme&revision=1712870458
 [2024-04-15 15:39 UTC] testing at example dot com
The following patch has been added/updated:

Patch Name: lxbfYeaa
Revision:   1713195564
URL:        https://bugs.php.net/patch-display.php?bug=80311&patch=lxbfYeaa&revision=1713195564
 [2024-04-15 15:39 UTC] testing at example dot com
The following patch has been added/updated:

Patch Name: lxbfYeaa
Revision:   1713195573
URL:        https://bugs.php.net/patch-display.php?bug=80311&patch=lxbfYeaa&revision=1713195573
 [2024-04-15 15:40 UTC] testing at example dot com
The following patch has been added/updated:

Patch Name: lxbfYeaa
Revision:   1713195653
URL:        https://bugs.php.net/patch-display.php?bug=80311&patch=lxbfYeaa&revision=1713195653
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 08:01:29 2024 UTC