weird behavior with SELECT #51
-
I made two docs : SELECT *,<-write<-user.*,<-write.* FROM article:surreal;
SELECT *,<-write.*,<-write<-user.* FROM article:surreal; the first query result is: [
{
"result": [
{
"<-write": [
{
"id": "write:ahtwyjik0ceqd8bgr8f1",
"in": "user:tobie",
"out": "article:surreal"
},
{
"id": "write:rpngdgkq4of4qla5crya",
"in": "user:tobie",
"out": "article:surreal",
"time": {
"written": "2022-08-23T04:34:37.981815668Z"
}
},
{
"id": "write:sd30wmksknj8z36l3dx7",
"in": "user:tobie",
"out": "article:surreal",
"time": {
"written": "2022-08-23T04:37:31.081179605Z"
}
},
{
"id": "write:svdraa53r7ajbujqti31",
"in": "user:tobie",
"out": "article:surreal"
}
],
"id": "article:surreal",
"title": "good"
}
],
"status": "OK",
"time": "222.435µs"
}
] the second query result is: [
{
"result": [
{
"<-write": [
{
"<-user": [
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
}
],
"id": "write:ahtwyjik0ceqd8bgr8f1",
"in": "user:tobie",
"out": "article:surreal"
},
{
"<-user": [
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
}
],
"id": "write:rpngdgkq4of4qla5crya",
"in": "user:tobie",
"out": "article:surreal",
"time": {
"written": "2022-08-23T04:34:37.981815668Z"
}
},
{
"<-user": [
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
}
],
"id": "write:sd30wmksknj8z36l3dx7",
"in": "user:tobie",
"out": "article:surreal",
"time": {
"written": "2022-08-23T04:37:31.081179605Z"
}
},
{
"<-user": [
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
}
],
"id": "write:svdraa53r7ajbujqti31",
"in": "user:tobie",
"out": "article:surreal"
}
],
"id": "article:surreal",
"title": "good"
}
],
"status": "OK",
"time": "231.269µs"
}
] I think it replaces new properties into the previous one? , so I tried this: SELECT *,<-write.*,<-write.in.* FROM article:surreal; [
{
"result": [
{
"<-write": [
{
"id": "write:ahtwyjik0ceqd8bgr8f1",
"in": [
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
}
],
"out": "article:surreal"
},
{
"id": "write:rpngdgkq4of4qla5crya",
"in": [
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
}
],
"out": "article:surreal",
"time": {
"written": "2022-08-23T04:34:37.981815668Z"
}
},
{
"id": "write:sd30wmksknj8z36l3dx7",
"in": [
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
}
],
"out": "article:surreal",
"time": {
"written": "2022-08-23T04:37:31.081179605Z"
}
},
{
"id": "write:svdraa53r7ajbujqti31",
"in": [
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
},
{
"id": "user:tobie",
"name": "tobie"
}
],
"out": "article:surreal"
}
],
"id": "article:surreal",
"title": "good"
}
],
"status": "OK",
"time": "152.997µs"
}
] I tried |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @ehsanonline thanks for starting this discussion! Two different things here:
SELECT *, <-write.in AS first, <-write AS second FROM article:surreal; However there is a better way of doing this, which only traverses once: SELECT *, <-(write AS first)<-(user AS second) FROM article:surreal;
|
Beta Was this translation helpful? Give feedback.
Hi @ehsanonline thanks for starting this discussion!
Two different things here:
SELECT *, <-write.in, <-write FROM article:surreal;
then the last<-write
field will overwrite the previous one. There is a way of getting round this. You could write something like the following:However there is a better way of doing this, which only traverses once:
DISTINCT
keyword into the graph traversal, so that it only pulls out distinct edges. Would be great to get y…