php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78331 mysql_xdevapi\CollectionFind::fields() path fails when ends in number
Submitted: 2019-07-24 13:37 UTC Modified: 2019-10-17 12:05 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: temuri416 at gmail dot com Assigned: marines (profile)
Status: Closed Package: MySQL related
PHP Version: 7.2.20 OS: Ubuntu16.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: temuri416 at gmail dot com
New email:
PHP Version: OS:

 

 [2019-07-24 13:37 UTC] temuri416 at gmail dot com
Description:
------------
->fields($expr) fails to fetch keys ["qwe", "asd"] when trying to reach them via "tree.100" path in the following document:

$doc = [
    'pk' => 25,
    'tree' => [
        100 => [
            'qwe' => [
                1
            ],
            'asd' => [
                'a'
            ]
        ],
        200 => 'a',
        'abc' => 999
    ]
];

Test script:
---------------
<?php
$doc = [
    'pk' => 25,
    'tree' => [
        100 => [
            'qwe' => [
                1
            ],
            'asd' => [
                'a'
            ]
        ],
        200 => 'a',
        'abc' => 999
    ]
];
$session = mysql_xdevapi\getSession('mysqlx://root:password@localhost');
$schema = $session->getSchema('test');
$coll = $schema->getCollection(COLL);
$coll->add($doc)->execute();

// Works correctly - fetches tree.100.qwe key.
$expr = mysql_xdevapi\Expression('$.tree."100".qwe');
$result = $coll->find('$.pk=25')->fields($expr)->execute();

// Errors with: mysql_xdevapi\CollectionFind::fields(): Error while parsing, details: CDK Error: After seeing '$.tree."100" AS ', looking at '100': Expected identifier after AS (cdk:8)
$expr = mysql_xdevapi\Expression('$.tree."100"');
$result = $coll->find('$.pk=25')->fields($expr)->execute();

// Errors with: mysql_xdevapi\CollectionFind::fields(): Error while parsing, details: CDK Error: After seeing '$.tree.', looking at '[100] ...': Expected member name or '*' after '.' in a document path (cdk:8)
$expr = mysql_xdevapi\Expression('$.tree.[100]');
$result = $coll->find('$.pk=25')->fields($expr)->execute();

// Errors with: mysql_xdevapi\CollectionFind::fields(): Error while parsing, details: CDK Error: After seeing '$.tree', looking at '.100 A...': Invalid characters in projection specification, only AS <name> allowed after the projection expression (cdk:8)
$expr = mysql_xdevapi\Expression('$.tree.100');
$result = $coll->find('$.pk=25')->fields($expr)->execute();


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-07-24 15:21 UTC] requinix@php.net
-Package: MySQL related +Package: MySQLi related -Assigned To: +Assigned To: johannes
 [2019-07-24 15:21 UTC] requinix@php.net
-Package: MySQLi related +Package: MySQL related
 [2019-08-19 07:50 UTC] marines@php.net
-Assigned To: johannes +Assigned To: marines
 [2019-08-19 07:52 UTC] marines@php.net
Following case:
$expr = mysql_xdevapi\Expression('$.tree."100"');
$result = $coll->find('$.pk=25')->fields($expr)->execute();
will be supported in version 8.0.18 which is planned for Oct 14.
 [2019-10-17 12:06 UTC] marines@php.net
-Status: Assigned +Status: Closed
 [2019-10-17 12:06 UTC] marines@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at
http://www.php.net/downloads.php

fixed in just released mysql_xdevapi v8.0.18
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jun 03 01:01:26 2025 UTC