{"action":"opened","issue":{"url":"https://api.github.com/repos/orientechnologies/orientdb/issues/6792","repository_url":"https://api.github.com/repos/orientechnologies/orientdb","labels_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/6792/labels{/name}","comments_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/6792/comments","events_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/6792/events","html_url":"https://github.com/orientechnologies/orientdb/issues/6792","id":181525568,"number":6792,"title":"Fetch plan fails when part of query","user":{"login":"borov333","id":22382033,"avatar_url":"https://avatars.githubusercontent.com/u/22382033?v=3","gravatar_id":"","url":"https://api.github.com/users/borov333","html_url":"https://github.com/borov333","followers_url":"https://api.github.com/users/borov333/followers","following_url":"https://api.github.com/users/borov333/following{/other_user}","gists_url":"https://api.github.com/users/borov333/gists{/gist_id}","starred_url":"https://api.github.com/users/borov333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/borov333/subscriptions","organizations_url":"https://api.github.com/users/borov333/orgs","repos_url":"https://api.github.com/users/borov333/repos","events_url":"https://api.github.com/users/borov333/events{/privacy}","received_events_url":"https://api.github.com/users/borov333/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-06T21:06:15Z","updated_at":"2016-10-06T21:06:15Z","closed_at":null,"body":"## OrientDB Version, operating system, or hardware.\r\n- v2.2.10\r\n\r\n## Operating System\r\n- [x] Linux\r\n- [x] MacOSX\r\n\r\n## Expected behavior and actual behavior\r\nExpected to get the query results with fetched linked objects when executing a query with or without parameters. However, the resulting object (JSON) is returned with @rids instead of the actual linked objects. The only way I can get linked objects is at the time of toJson(\"fetchPlan:....\"). But, I believe it will call the remote database second time, which unnecessary creates latency.\r\n\r\n## Steps to reproduce the problem\r\n\r\nCLASS 'LeadCategory'\r\nPROPERTIES\r\n+----+--------------+-------+------------+---------+--------+--------+----+----+-------+-------+\r\n|#   |NAME            |TYPE   |LINKED-TYPE/CLASS|MANDATORY|READONLY|NOT-NULL|MIN |MAX |COLLATE|DEFAULT|\r\n+----+--------------+-------+------------+---------+--------+--------+----+----+-------+-------+\r\n|0   |presetAttributes|LINKSET|PresetAttribute  |false    |false   |false   |    |    |default|       |\r\n|1   |className       |STRING |                 |true     |false   |true    |    |    |default|       |\r\n|2   |id              |INTEGER|                 |true     |true    |true    |    |    |default|       |\r\n+----+--------------+-------+------------+---------+--------+--------+----+----+-------+-------+\r\n\r\nHere are few failing queries:\r\nQuery 1 - Fails\r\nList<ODocument> result = db.query(new OSQLSynchQuery<ODocument>(\"select from LeadCategory where id = 1\").setFetchPlan(\"*:-1\"));\r\nresult.get(0).toJSON();\r\n\r\nIt produces the following json\r\n{\"@type\":\"d\",\"@rid\":\"#45:1\",\"@version\":1,\"@class\":\"LeadCategory\",\"id\":1,\"className\":\"TempLead\",\"presetAttributes\":[\"#80:0\",\"#79:0\"],\"@fieldTypes\":\"presetAttributes=n\"}\r\n\r\nQuery 2 - Fails\r\nString sql = \"select from LeadCategory where id = ?\";\r\nOSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>(sql);\r\nquery.setFetchPlan(\"*:-1\");\r\nList<ODocument> result = db.command(query).execute(categoryId);\r\nresult.get(0).toJSON();\r\n\r\nIt produces the same json\r\n{\"@type\":\"d\",\"@rid\":\"#45:1\",\"@version\":1,\"@class\":\"LeadCategory\",\"id\":1,\"className\":\"TempLead\",\"presetAttributes\":[\"#80:0\",\"#79:0\"],\"@fieldTypes\":\"presetAttributes=n\"}\r\n\r\nQuery 3 - Succeeds\r\nString sql = \"select from LeadCategory where id = ?\";\r\nOSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>(sql);\r\nList<ODocument> result = db.command(query).execute(categoryId);\r\nresult.get(0).toJSON(\"fetchPlan:*:-1\");\r\n\r\nproduces correct json\r\n{\"id\":1,\"className\":\"TempLead\",\"presetAttributes\":[{\"name\":\"utilityCompany\",\"values\":[\"American Electric Power\",\"Azusa Light & Water\",\"Black Hills Energy\",\"Bryan Texas Utilities\",\"California Public Utilities Commission\",\"Central Maine Power\",\"City & County of San Francisco\",\"Duke Energy Indiana\",\"Excel Energy\",\"Georgia Power\",\"Guadalupe Valley Electric Cooperative\",\"High West Energy\"]},{\"name\":\"contactTime\",\"values\":[\"anytime\",\"morning\",\"afternoon\",\"evening\"]}]}\r\n\r\nSo, that was problem #1. \r\nAlso, as a problem #2, I spotted that I can't attach the fetch plan like in your docs example in the fluent function manner:\r\nOSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>(sql).setFetchPlan(\"*:-1\");\r\n\r\nInstead, I had to split the functions, which didn't work (as per problem #1 above), like:\r\nOSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>(sql);\r\nquery.setFetchPlan(\"*:-1\");\r\n\r\nLet me know if I'm doing something wrong. This is my first time playing with fetching :)\r\n\r\n"}}
{"actor":{"display_login":"borov333"}}