Bug #78331 [Com]: mysql_xdevapi\CollectionFind::fields() path fails when ends in number
| From: | marines@php.net | Date: | Mon, 19 Aug 2019 07:52:51 +0000 |
| Subject: | Bug #78331 [Com]: mysql_xdevapi\CollectionFind::fields() path fails when ends in number | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-222314@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78331&edit=1
ID: 78331
Comment by: marines@php.net
Reported by: temuri416 at gmail dot com
Summary: mysql_xdevapi\CollectionFind::fields() path fails
when ends in number
Status: Assigned
Type: Bug
Package: MySQL related
Operating System: Ubuntu16.04
PHP Version: 7.2.20
Assigned To: marines
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2019-07-24 13:37:55] 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();
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78331&edit=1