Can't update multi link with link property
See original GitHub issueI cannot figure out how to update multi links with link properties. Everything I try results in the error: QueryError: invalid reference to link property in top level shape.
To illustrate using an example from the docs (bottom of this page), here’s a simple schema:
type User {
property name -> str;
multi link friends -> User {
property nickname -> str;
}
}
As the docs demonstrate, I can insert all the users and use the WITH + FOR + array_unpack statement to set multiple links and their corresponding link properties.
But now if I add another user and want to update any of the existing users’ friends list with a link and a link property, it just doesn’t happen. The following (and all permutations I could think of as far as adding and removing round brackets) does not work:
WITH U2 := User UPDATE User FILTER .name = 'Bob'
SET {
friends := User.friends UNION (
SELECT U2 { @nickname := 'new guy' } FILTER U2.name = 'John'
)
};
Result: QueryError: invalid reference to link property in top level shape with the error arrow pointing to the beginning of the { @nickname
… part
Note that just without the link property part I am able to add the new friend to the friends list using the query above.
I am also able to add the link with its link property if I replace all existing friends (by omitting User.friends UNION). So clearly this should be possible, but I can’t find/understand my syntax error.
Thanks for your help!
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
This looks like a bug. Your query should work. I’ll take a look soon. Also, #165 will make these sorts of queries much simpler. Meanwhile, the following workaround should work (at least in nightly):
The
+=
shape operator is now supported inUPDATE
, so the original query can be written as: