How flexible is the database?

70 views
Skip to first unread message

hartmut bischoff

unread,
Jul 31, 2015, 3:41:29 AM7/31/15
to OrientDB

Hi altogether,

I'm still working on the Ruby-ORM-Adapter to OrientDB, focussing on the behavior of embedded lists, lightweight edges
In Ruby they are serialized as ordinary Arrays. Thus - they should behave like Arrays in the ORM-Adapter, too.

In Ruby  the method "<<" is used to add an element to an array, thus in activeOrient after initializing the Classes TestMode and LinkClass this code

 59      new_record = TestModel.new_instance ll: [ ]                            # new document with an empty array
 60       (1..9).each do |i|
 61         new_record.ll << LinkClass.new_instance( att: "#{i} attribute" )    
 62         new_record.ll << i
 63       end


creates an Array with 18 Elements:

1 attribute ; 1 ; 2 attribute ; 2 ; 3 attribute ; 3 ; 4 attribute ; 4 ; 5 attribute ; 5 ; 6 attribute ; 6 ; 7 attribute ; 7 ; 8 attribute ; 8 ; 9 attribute ; 9
  

each  link to the LinkClass-Instance  is followed by a Number 

Now the surprise. When checking the Record in Studio I got:

METADATAPROPERTIES
@rid
@version
@class
ll
created_at
updated_at
7
[5,"t",78]
2015-07-31T09:13:14.736 02:00
2015-07-31T09:13:14.736 02:00
19


The Numeric-Items are ignored, only the links are displayed, and only 9 Array-Elements are detected.

However, if I reverse the order of entries (adding first the number then the link), Studio does not recognize the links but displays all elements.

METADATAPROPERTIES
@rid
@version
@class
ll
created_at
updated_at
7
[5,"t",78]
2015-07-31T09:30:43.522 02:00
2015-07-31T09:30:43.522 02:00
19
[1,"#33:0",2,"#33:1",3,"#33:2",4,"#33:3",5,"#33:4",6,"#33:5",7,"#33:6",8,"#33:7",9,"#33:8"]

    Am I bending the Datamodel of Orientdb to much or is this just a bug in studio?

    hartmut bischoff

    unread,
    Aug 5, 2015, 5:10:50 AM8/5/15
    to OrientDB
    By further investigating ...

    the Array not recognized correctly by Studio can be queried the usual way:

    select from (select expand(ll) from ModelTest ) where att like '4%'

    returns an Array with expanded TestLinkClasses starting with

    {
        "result": [
            {
                "@type": "d",
                "@rid": "#10:3",
                "@version": 1,
                "@class": "TestLinkClass",
                "att": "4 attribute"
            },


    Thus I guess that's valid to store unsorted data in an array. And I am able to use the embedded properties in the usual manner, no matter how »chaotic« the array is organized.

     
    Reply all
    Reply to author
    Forward
    0 new messages