Ostico / PhpOrient

PhpOrient - Official Php driver based on the binary protocol of OrientDB.
Other
68 stars 37 forks source link

Incorrect RID position, when fetched into Bag object #7

Closed aurelijusb closed 9 years ago

aurelijusb commented 9 years ago

Script to reproduce:

use PhpOrient\PhpOrient;
require "vendor/autoload.php";

header('Content-type: text/plain');
$config = [
    'username' => 'root',
    'password' => 'root_pass', // Change here
    'hostname' => 'localhost',
    'port' => 2424,
    'db' => 'testReferenceFields' . time() // Change here
];

try {
    $client = new PhpOrient();
    $client->configure($config);
    $client->connect();

    $clusterId = $client->dbCreate(
        $config['db'],
        PhpOrient::STORAGE_TYPE_MEMORY,
        PhpOrient::DATABASE_TYPE_GRAPH
    );
    $client->dbOpen($config['db']);

    $client->sqlBatch('
        create class Node extends V;
        create class Parent extends E;
        let top = create vertex Node set pos="top";
        let left = create vertex Node set pos="left";
        let right = create vertex Node set pos="right";
        create edge Parent from $left to $top;
        create edge Parent from $right to $top;
    ');
    $result = $client->query('SELECT in_Parent, in("Parent") FROM V WHERE pos="top"', 1)[0];
    $listElements = $result['in'];
    foreach ($result['in_Parent'] as $id) {
        print "in_parent: $id\n";  // $result['in_Parent'] is Bag object
    }
    foreach ($result['in'] as $id) {
        print "in(Parent): $id\n"; // $result['in'] is array of Id objects
    }

} catch (Exception $e) {
     var_dump($e);
}

Unexpected result:

in_parent: #11:3096224743817216
in_parent: #11:3096224743817216
in(Parent): #11:1
in(Parent): #11:2 

Expected result:

in_parent: #11:1
in_parent: #11:2
in(Parent): #11:1
in(Parent): #11:2

Environment:

Notes:

Same results, when loading with recordLoad.

Ostico commented 9 years ago

Thank you, was related to another bug. Now it is fixed.

Result ( even in 32bit/64bit systems ):
in_parent: #12:0
in_parent: #12:1
in(Parent): #11:1
in(Parent): #11:2

Result from OrientDB console:
# select expand( in(Parent) ) from V where pos="top";

----+-----+------+-----+----------
#   |@RID |@CLASS|pos  |out_Parent
----+-----+------+-----+----------
0   |#11:1|Node  |left |[size=1]
1   |#11:2|Node  |right|[size=1]
----+-----+------+-----+----------

# select  expand(in_Parent) from V where pos="top";

----+-----+------+-----+-----
#   |@RID |@CLASS|out  |in
----+-----+------+-----+-----
0   |#12:0|Parent|#11:1|#11:0
1   |#12:1|Parent|#11:2|#11:0
----+-----+------+-----+-----