Nested projections

The documentation describes the power of nested projections like

SELECT name, parent.name FROM TheClass WHERE name = 'baz'

The expected result is a list [name, parent-name]

I tried this example

CREATE VERTEX person CONTENT {"name":"Reimund"}  # #25:0
CREATE VERTEX person CONTENT {"name":"Eva"}    # #26:0
CREATE VERTEX person CONTENT {"name":"Ulli"}
CREATE VERTEX person CONTENT {"name":"Uwe"}
CREATE VERTEX person CONTENT {"name":"George"}
CREATE VERTEX person CONTENT {"name":"Hugo",
                             "father":"#25:0",
                             "children":["#26:0","#27:0","#28:0","#29:0"]}

Then

 select father:{name} from person

should return just the names of the dataset referenced by the link.
Instead the record (rid) is returned

In addition

 select father{:name}  from person  where children contains( name= "Uwe") 
#or
select children.name from person where father.name = 'Reimund" #  same with father['name'] =

should return some values, but return null

+ FETCH FROM CLASS person
  + FETCH FROM CLUSTER 25 ASC
  + FETCH FROM CLUSTER 26 ASC
  + FETCH FROM CLUSTER 27 ASC
  + FETCH FROM CLUSTER 28 ASC
  + FETCH FROM CLUSTER 29 ASC
  + FETCH FROM CLUSTER 30 ASC
  + FETCH FROM CLUSTER 31 ASC
  + FETCH FROM CLUSTER 32 ASC
  + FETCH NEW RECORDS FROM CURRENT TRANSACTION SCOPE (if any)
+ FILTER ITEMS WHERE 
  father.name = "Reimund"
+ CALCULATE PROJECTIONS
  children :{name}

(Version 3.0.22)

Where is my error?

P.S. I know, that such queries did work in V2.2

Hi,
I tryed you case following your steps and I have the same issue but, I’ve been able to get the expect result by following these steps:

CREATE CLASS person EXTENDS V
CREATE PROPERTY person.name STRING
INSERT INTO person (name) VALUES ("Reimund"),("Eva"),("Uwe"),("George")
INSERT INTO person (name, father, children) VALUES ("Hugo", #25:0, ["#26:0","#27:0","#28:0","#29:0"])

this is the result I got:

image

Hope it helps.

Regards,
Michela

Ah … eine Insel…
After declaring a property link for father this query works as expected

 INFO->MATCH {class: person, as: people, where: ( father.name = 'Reimund' ) } RETURN people.name
 => [{:"people.name"=>"Hugo"}, {:"people.name"=>"Pete"}] 
# and (ActiveOrient-query)
Person.query.where( 'father.name' => 'Reimund').projection('name').execute
27.07.(17:24:30) INFO->select name from person where father.name = 'Reimund' 
 => [{:name=>"Hugo"}, {:name=>"Pete"}] 

Lesson learned: nested projections only work in a strict schema environment

But…

 > pete = Person.create name: 'Pete', 
 >                        father: Person.upsert( where: {name: "Reimund"} ),
 >                        children: ["Eva", "Mathew" ].map{|c| Person.create( name: c) }
# INFO->update person set name = 'Reimund' upsert return after $current where name = 'Reimund'
# INFO->CREATE VERTEX person CONTENT {"name":"Eva"}
# INFO->CREATE VERTEX person CONTENT {"name":"Mathew"}
# INFO->CREATE VERTEX person CONTENT {"name":"Pete","father":"#25:3","children":["#26:3","#27:3"]}
28.07.(18:15:57)ERROR->com.orientechnologies.orient.core.exception.OValidationException: 
The field 'person.children' has been declared as LINKLIST but the value is not a record or a record-id

An Array of rid’s of the proper class should fit the LINKLIST definitions.
Is there any possible format of the json content which will satisfy the conditions for inserting a linklist?

Hi @topo

i think it’s not matter of schema or schemaless, but more of CONTENT syntax which parses JSON and it’s not able to recognise links, and treat your input as a plain string

If you use this without content will work

CREATE VERTEX person SET name = "Hugo", father = #25:0, children = [#26:0,#27:0,#28:0,#29:0]

let me know if this helps

Thanks

Yes, that fixed it. Thanks.
So sad, that either the documentation or the implementation is buggy.

Just published an article covering the very basics of links and joins in Orientdb using ActiveOrient

https://dev.to/topofocus/activeorient-joins-and-links-j2d