nested records not fetched
When a query includes nested records, pyorient does not include the nested records, but rather a link to the nested record (or tries to, in the case of temporary records, see #209). Orient Studio returns the nested records themselves. This is particularly an issue in the case of temporary records, as you can't simply select the temporary record in a separate query.
For example, with the query select 1, $t let $t=(select 1), the oRecordData of the first record is (with my monkey patch to fix temporary record links):

The result is the same with non-temporary records, example select 1, $t let $t=(select from some_table limit 1) fetchplan *:1:

While Studio includes the actual nested record data:

Raw response as shown in Studio:
{
"result": [
{
"1": 1,
"@type": "d",
"@rid": "#-2:3",
"@version": 0,
"$t": [
{
"1": 1,
"@type": "d",
"@rid": "#-2:1",
"@version": 0
}
],
"@fieldTypes": "$t=z"
}
],
"notification": "Query executed in 0.043 sec. Returned 1 record(s)"
}
Studio also properly includes the nested data automatically for temporary records (like (select 1)), and includes the nested data for a persisted record when using an appropriate fetchplan. (I won't show an example here as I can't share details of our data or structures).
My current workaround is to convert the result to JSON in my query (select @this.toJSON() as data from (...)), then parse the returned JSON in Python.
Hi,
Can you share some code snippets on how you are processing the (select @this.toJSON() as data from (...))? I has a similar query but was getting a JSON serialisation issue? Refer my issue 217 just posted?
Thanks
@kfloz
process = respond
if jsonify:
def process(v):
return respond(loads(v.oRecordData['data']))
query = 'SELECT @this.toJson() AS data FROM ({})'.format(query)
result = self.client_command(query)
response = [process(v) for v in result]
respond() is my helper for preparing a response for use in my application, self.client_command() is simply a reconnecting wrapper around OrientDB().command().
As noted in the responses to your issue #217, the result will still be an OrientDB record response with a single field - by default it will be named this, I just prefer to alias it as data.