orientechnologies / PhpOrient

PhpOrient - PHP binary client for OrientDB
Other
107 stars 13 forks source link

Fetchplan doesn't work #3

Closed micha-heigl closed 9 years ago

micha-heigl commented 9 years ago

Hi, I have the follwing query:

$db->query('select address from user', 1, '*:1');

where address is a LINKSET. The result is an array of Record-IDs, why doesn't the fetchplan *:1 include the address?

In studio everything works as expected. I also tried this with the example db GratefulDeadConcerts:

$db->query('select out("sung_by") from #9:1', 1, '*:1');

The result should contain 'name': 'Garcia', but only a PhpOrient\Protocols\Binary\Data\ID object is returned with value "#9:8"

Is fetchplan not implemented yet in the beta?

nicolapetracchi commented 9 years ago

Any update about this?

I got a quick look at the code, in the _read_prefetch_record for each fetched documents there is a async-result-type of type 2 which actually invoke a closure that is empty, thus this lead nowhere and the acquired document structures are simply ignored.

How should be represented those linked documents into the result?

Ostico commented 9 years ago

Hi @nicolapetracchi ,

sorry for the delay, but i'm really busy in this period. I've been no time to check your issue, but regarding the empty closure, you should use that function in this manner:

https://github.com/orientechnologies/PhpOrient#make-an-async-query--callback-

Ostico commented 9 years ago

Hi @micha-nerdlichter ,

i tried with your example code from orientdb console ( console.sh ). There is not a bug or issue, even the console returns the same result, the linkset are not expanded by default.

From the console:

orientdb {db=GratefulDeadConcerts}> select out("sung_by") from #9:1        

----+------+----
#   |@CLASS|out 
----+------+----
0   |null  |[1] 
----+------+----

If you want to expand the record, the fetchplan is not needed, you must use this syntax:

$db->query('select expand( out("sung_by") ) from #9:1');

In the console you will obtain the same result:

orientdb {db=GratefulDeadConcerts}> select expand( out("sung_by") ) from #9:1

----+----+------+----------+-------------+------+------
#   |@RID|@CLASS|in_sung_by|in_written_by|name  |type  
----+----+------+----------+-------------+------+------
0   |#9:8|V     |[size=-1] |[size=4]     |Garcia|artist
----+----+------+----------+-------------+------+------

You can referrer to these links: http://www.orientechnologies.com/orientdb-improved-sql-filtering/ http://www.orientechnologies.com/docs/last/Fetching-Strategies.html

nicolapetracchi commented 9 years ago

That's correct, though the HTTP API returns a JSON representation of "traversed" data as it could be predictable for the use of a FETCHPLAN, as I mentioned before, not in a clear way though, the fetched entities are provided by the binary protocol with the response, so IMHO seems like console is not much reliable as a reference in this case.