Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPDATE #9:1 SET foo.bar = (INSERT INTO...) Syntax Not Working #8583

Closed
big213 opened this issue Oct 5, 2018 · 8 comments
Closed

UPDATE #9:1 SET foo.bar = (INSERT INTO...) Syntax Not Working #8583

big213 opened this issue Oct 5, 2018 · 8 comments
Assignees
Labels
Milestone

Comments

@big213
Copy link

big213 commented Oct 5, 2018

OrientDB Version: 3.0.8

Java Version: 1.8.0_141

OS: Windows 7

Expected behavior

UPDATE ... SET foo.bar = (INSERT INTO...) successfully updates the linkmap with the inserted record (it worked fine in OrientDB 2.2x)

Actual behavior

Fails, returns java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.orientechnologies.orient.core.db.record.OIdentifiable

Steps to reproduce

CREATE VERTEX V SET foo = {}
UPDATE #9:1 SET foo.bar = (INSERT INTO V SET val = 1)

What does work is if I do:
CREATE VERTEX V SET id = 1, foo = {} //#9:1
CREATE VERTEX V SET id = 2 //#9:2
UPDATE #9:1 SET foo.bar = #9:2 OK

@big213
Copy link
Author

big213 commented Oct 5, 2018

It appears that the same issue occurs with the map() function. Consider this example, where I try to create vertex and populate a linkmap in the same query. Maybe this kind of syntax is too much, but should there be a way to do this kind of action in the same query?

CREATE VERTEX V SET foo = map("key1", (INSERT INTO V SET id = 1), "key2", (INSERT INTO V SET id = 2))

@luigidellaquila luigidellaquila self-assigned this Oct 5, 2018
luigidellaquila added a commit that referenced this issue Oct 5, 2018
@luigidellaquila
Copy link
Member

Hi @big213

I just pushed a fix to 3.0.x branch, it will be released with v 3.0.9

Thanks

Luigi

@big213
Copy link
Author

big213 commented Oct 6, 2018

@luigidellaquila Thank you for the quick attention to this issue. However, I just hope that the fix will also address the following query, could you please check?

CREATE VERTEX V SET foo = map("key1", (INSERT INTO V SET id = 1), "key2", (INSERT INTO V SET id = 2))

@luigidellaquila
Copy link
Member

Hi @big213

Subqueries in that context are not supported by the SQL executor (for now at least)

Thanks

Luigi

@big213
Copy link
Author

big213 commented Oct 9, 2018

@luigidellaquila thanks for letting me know. I believe it was working as recently as OrientDB 3.0.7, so it is a bit unfortunate that it is no longer supported. How about this query, will it be supported in 3.0.9?

CREATE VERTEX V SET foo = { "key1": (INSERT INTO V SET id = 1), "key2": (INSERT INTO V SET id = 2) }

or...

CREATE VERTEX V SET foo = {}, foo.key1 = (INSERT INTO V SET id=1), foo.key2 = (INSERT INTO V SET id=2) (this worked in OrientDB 2.2.x)

Basically, I'm looking for a way to create and populate a linkmap in the same query.

@luigidellaquila
Copy link
Member

Hi @big213

I'd say it's quite unlikely, it never worked in v 3.0.x.
We will likely support it in the near future.

Thanks

Luigi

@big213
Copy link
Author

big213 commented Oct 17, 2018

Hi @luigidellaquila

It looks like OrientDB 3.0.9 has been released, and I tried to test if these queries were functional:

CREATE VERTEX V SET foo = {}
UPDATE #9:1 SET foo.bar = (INSERT INTO V SET val = 1)

This will work with no defined fields, but if field foo has been defined as a LINKMAP on V, it will still return the following error:

java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.orientechnologies.orient.core.db.record.OIdentifiable

luigidellaquila added a commit that referenced this issue Oct 17, 2018
luigidellaquila added a commit that referenced this issue Oct 17, 2018
@luigidellaquila
Copy link
Member

Hi @big213

I just pushed another fix, now it should be OK also in that case

Thanks

Luigi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants