fetchPlan returning extra properties
See original GitHub issueI’m using OrientDB v.2.1.1 with useLightweightEdges property set to true. Using fetchPlan queries often return extra properties non included in the query or even some of properties excluded in more ways.
Here is an example:
Given this simple structure
User V #13
Event V #14
Org V #15
Media V #16
admin E User --> Org
follow E User --> Org
author E Event --> Org
avatar E Org --> Media
thumb E Event --> Media
I need to write a query that fetches a specific Event, its relative thumb, author and the author’s avatar. Nothing else.
1st query:
SELECT @this.toJSON('rid,class,fetchPlan:[*]in_*:-2 [*]out_*:-2 out_thumb:0 out_author:0 out_author.out_avatar:0') FROM Event WHERE @rid = #14:8
Returns:
{
"@rid": "#14:8",
"@class": "Event",
"name": "EVENT_TEST",
"out_author": [
{
"@rid": "#15:0",
"@class": "Org",
"name": "ORG_TEST",
! "in_admin": [ "#13:0", "#13:5", "#13:6", "#13:9", "#13:10", "#13:13" ],
! "in_follow": [ "#13:0", "#13:4", "#13:5", "#13:6", "#13:14", "#13:15" ],
! "in_author": [ "#14:6", "#14:7", "#14:8", "#14:9", "#14:10", "#14:11" ],
"out_avatar": [
{
"@rid": "#16:2",
"@class": "Media",
"url": "www.image.com",
! "in_thumb": [ "#14:4", "#14:6", "#14:7", "#14:12", "#14:14", "#14:15" ],
! "in_avatar": [ "#15:0" ]
}
]
}
],
"out_thumb": [
{
"@rid": "#16:1",
"@class": "Media",
"url": "www.image.com",
! "in_thumb": [ "#14:2", "#14:5", "#14:8", "#14:9", "#14:10", "#14:13" ],
! "in_avatar": [ "#15:2" ]
}
]
}
Where these properties should have been excluded:
out_author.in_admin
out_author.in_follow
out_author.in_author
out_author.out_avatar.in_thumb
out_author.out_avatar.in_avatar
out_thumb.in_thumb
out_thumb.in_avatar
2nd query:
made by adding some parameters to the 1st query to explicitly exclude the extra properties
SELECT @this.toJSON('rid,class,fetchPlan:[*]in_*:-2 [*]out_*:-2 out_thumb:0 out_author:0 out_author.out_avatar:0 [*]in_avatar:-2 [*]in_thumb:-2 [*]in_author:-2 [*]in_admin:-2 [*]in_follow:-2') FROM Event WHERE @rid = #14:8
Returns
{
"@rid": "#14:8",
"@class": "Event",
"name": "EVENT_TEST",
"out_author": [
{
"@rid": "#15:0",
"@class": "Org",
"name": "ORG_TEST",
! "in_admin": [ "#13:0", "#13:5", "#13:6", "#13:9", "#13:10", "#13:13" ],
! "in_follow": [ "#13:0", "#13:4", "#13:5", "#13:6", "#13:14", "#13:15" ],
"out_avatar": [
{
"@rid": "#16:2",
"@class": "Media",
"url": "www.image.com"
}
]
}
],
"out_thumb": [
{
"@rid": "#16:1",
"@class": "Media",
"url": "www.image.com"
}
]
}
Partially works since removes
out_author.in_author
out_author.out_avatar.in_thumb
out_author.out_avatar.in_avatar
out_thumb.in_thumb
out_thumb.in_avatar
But it doesn’t remove
out_author.in_admin
out_author.in_follow
3nd query:
made by adding some parameters to the 2st query to even more explicitly exclude the extra properties remained
SELECT @this.toJSON('rid,class,fetchPlan:[*]in_*:-2 [*]out_*:-2 out_thumb:0 out_author:0 out_author.out_avatar:0 [*]in_avatar:-2 [*]in_thumb:-2 [*]in_author:-2 [*]in_admin:-2 [*]in_follow:-2 out_author.in_admin:-2 out_author.in_follow:-2') FROM Event WHERE @rid = #14:8
Returns:
// The same as for 2nd query
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
…even nicer: use “as” to rename the edges:
I don’t understand why you are using the toJSON-function, this looks so complicated… why not use the outE()-function with include()?
Btw if you replace the
... from Event where @rid
withselect ... from #14:8
your query is faster.