那是因为提供的 Hash 被转换为嵌入式类。
也许看看 ActiveOrientWiki https://github.com/topofocus/active-orient/wiki/Relations
解释:拿一个类base
,有一个具有两个属性(无模式)的文档并将现有文档添加到其中
( 0..9 ).each do | b |
base_record= Base.create label: b, first_list: []
( 0..9 ).each {|c| base_record.first_list << FirstList.create( label: c ) }
end
INFO->CREATE VERTEX base CONTENT {"label":0,"first_list":[]}
INFO->CREATE VERTEX first_list CONTENT {"label":0}
INFO->update #136:0 set first_list = first_list || [#147:0] return after @this
然后嵌入链接,记录看起来像
=> #<Base:0x00000000041a60e0 @metadata={:type=>"d", :class=>"base", :version=>11, :fieldTypes=>"first_list=z", :cluster=>129, :record=>1},
@attributes={:first_list=>["#149:1", "#150:1", "#151:1", "#152:1", "#145:2", "#146:2", "#147:2", "#148:2", "#149:2", "#150:2"], :label=>"1"}>
如果展开列表项,可以查询“@type”
如果你添加一个没有删除的文档,同样的事情会发生
( 0..9 ).each {|c| base_record.first_list << FirstList.new( label: c ) }
20.04.(12:53:59) INFO->update #130:2 set first_list = first_list || [{ @type: 'd' ,@class: 'first_list' ,label: 0 }] return after @this
INFO->CREATE VERTEX base CONTENT {"label":"c","first_list":[]}
'#130:2'.expand
=> #<Base:0x00000000043927a0 @metadata={:type=>"d", :class=>"base", :version=>11, :fieldTypes=>"first_list=z", :cluster=>130, :record=>2},
@attributes={:first_list=>["#151:12", "#152:12", "#145:13", "#146:13", "#147:13", "#148:13", "#149:13", "#150:13", "#151:13", "#152:13"], :label=>"c"}>
如果省略类名,则只有 rid 的变化范围
INFO-> update #132:2 set first_list = first_list || { @type: 'd' ,label: 0 } return after @this
=> [#<Base:0x0000000003a26fb8 @metadata={:type=>"d", :class=>"base", :version=>3, :fieldTypes=>"first_list=z", :cluster=>132, :record=>2},
@attributes={:first_list=>["#3:0"], :label=>"d"}>]
无论如何,查询@type
失败