|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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();
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 19:00:02 2025 UTC |
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.