编辑:请参见底部,以便在较小的统计/架构集上重现问题
我正在围绕OrientDB时间序列用例进行试验,并且我试图链接两棵树的每个级别。所以我做了这个sql批处理:
let $w1 = select expand(W1[2406]) from #12:2;
let $w2 = select expand(W1[2407]) from #12:2;
let $d1 = select expand(D1[4]) from $w1;
let $d2 = select expand(D1[0]) from $w2;
let $h1 = select expand(H1[23]) from $d1;
let $h2 = select expand(H1[0]) from $d2;
let $m1 = select expand(M1[59]) from $h1;
let $m2 = select expand(M1[0]) from $h2;
update $w1 set next = $w2;
update $w2 set previous = $w1;
update $d1 set next = $d2;
update $d2 set previous = $d1;
update $h1 set next = $h2;
update $h2 set previous = $h1;
update $m1 set next = $m2;
update $m2 set previous = $m1;
但是我在第一次更新时遇到了这个错误:
The field 'W1.next' has been declared as LINK but the value is not a record or a record-id
......我不明白,因为当我尝试:
return [$w1, $w2, $d1, $d2, $h1, $h2, $m1, $m2];
我按预期获得了记录......
所以有两个问题:
(注意:我想留在sql / batch sql中)
这些课程是这样的:
Symbol{
W1 : LINKMAP W1
}
W1 {
next : LINK W1
previous : LINK W1
D1 : LINKMAP D1
}
D1 {
next : LINK D2
previous : LINK D2
H1 : LINKMAP H1
}
H1 [...]
M1 [...]
编辑:如何在较小的数据集上重现问题:
架构创建:
create class A extends V;
create class B extends V;
create property A.B LINKMAP B;
create property B.B LINK B;
注意:A.B是B元素的数组,B.B是1to1链接
要插入的虚拟值:
insert into B CONTENT {}
insert into B CONTENT {}
现在,将两个假人的rid插入A
select from B
现在插入以下两项(我的情况为#13:0
和#13:1
)
insert into A(B) values ({'0' : #13:0, '1' : #13:1})
insert into A(B) values ({'0' : #13:0, '1' : #13:1})
最后,试试这批:
let $b1 = select expand(B[0]) from A;
let $b2 = select expand(B[1]) from A;
update $b1 SET B = $b2;
update $b2 SET B = $b1;
你看错了
该领域' B.B'已被声明为LINK但该值不是记录或记录ID
但如果你这样做:
let $b1 = select expand(B[0]) from A;
let $b2 = select expand(B[1]) from A;
return $b1;
和
let $b1 = select expand(B[0]) from A;
let $b2 = select expand(B[1]) from A;
return $b2;
和
let $b1 = select expand(B[0]) from A;
let $b2 = select expand(B[1]) from A;
return {'b1': $b1, 'b2' : $b2};
你可以看到它们不是集合,而是真正的记录
EDIT2 Isavio提供的解决方案有效,但我想知道它为什么会这样,因为在之前的结果中,它们似乎不是收集?
let $b1 = select expand(B[0]) from A;
let $b2 = select expand(B[1]) from A;
update $b1 SET B = $b2[0];
update $b2 SET B = $b1[0];
答案 0 :(得分:1)
更新的结果是否可能是记录的集合?你能尝试使用:
.....
update $w1 set next = $w2[0];
....
修改强>
我认为使用LET将始终是一个集合。