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

insert ... return $current.link1:{field1} syntax returns null in develop branch #8543

Closed
freeart opened this issue Sep 17, 2018 · 7 comments
Closed
Assignees
Labels
Milestone

Comments

@freeart
Copy link

freeart commented Sep 17, 2018

OrientDB Version: current develop branch

Java Version: docker openjdk:8-jdk-alpine

OS: docker openjdk:8-jdk-alpine

Expected behavior

{id: "xxx", name: "xxx"}  

Actual behavior

{id: null, name: null}  

Update and Select works fine, but Insertdoesn't return values of fields of LINK type.

Steps to reproduce

insert into `Table`
set code = #27:49 
RETURN $current.code:{id,name}
@luigidellaquila luigidellaquila self-assigned this Sep 17, 2018
@luigidellaquila
Copy link
Member

Hi @freeart

I just tried the following on develop branch and it seems to work fine

create class Table;
create class Code;

insert into Code set id = 10, name= 'foo';

insert into `Table` set code = #242:0 RETURN $current.code:{id,name};

Am I missing something?

Thanks

Luigi

@freeart
Copy link
Author

freeart commented Sep 18, 2018

I found the difference between your query and my query. I think it is a bug

create class TCode;
CREATE PROPERTY `TCode`.`id` STRING
ALTER PROPERTY `TCode`.`id` mandatory true
ALTER PROPERTY `TCode`.`id` readonly false
ALTER PROPERTY `TCode`.`id` notNull true
CREATE PROPERTY `TCode`.`name` STRING
ALTER PROPERTY `TCode`.`name` mandatory true
ALTER PROPERTY `TCode`.`name` readonly false
ALTER PROPERTY `TCode`.`name` notNull true

create class TTable;
CREATE PROPERTY `TTable`.`code` LINK  `TCode`
ALTER PROPERTY `TTable`.`code` linkedClass "TCode"
ALTER PROPERTY `TTable`.`code` mandatory true
ALTER PROPERTY `TTable`.`code` readonly false
ALTER PROPERTY `TTable`.`code` notNull true
CREATE PROPERTY `TTable`.`name` STRING
ALTER PROPERTY `TTable`.`name` mandatory true
ALTER PROPERTY `TTable`.`name` readonly false
ALTER PROPERTY `TTable`.`name` notNull true

insert into TCode set id = 10, name= 'foo';

So, this sql

insert into `TTable` 
set 
	code = (SELECT @rid from TCode WHERE id = 10),
    name = "test"
RETURN 
	$current.code:{id,name} as code,
    $current.name as name;

returns {"id":null,"name":null} | test
but,

insert into `TTable` 
set 
	code = (SELECT from TCode WHERE id = 10),
    name = "test"
RETURN 
	$current.code:{id,name} as code,
    $current.name as name;

returns {"id":10,"name":"foo"} | test

@luigidellaquila
Copy link
Member

OK, it makes sense, SELECT @rid from TCode returns a projection with a single column, not a full document with its attributes, so you have to refer to that column to

Just to clarify, both the following will work fine:

insert into `TTable` 
set 
	code = (SELECT @rid from TCode WHERE id = 10),
    name = "test"
RETURN 
	$current.code.@rid:{id,name} as code,
    $current.name as name;
insert into `TTable` 
set 
	code = (SELECT @rid as foo from TCode WHERE id = 10),
    name = "test"
RETURN 
	$current.code.foo:{id,name} as code,
    $current.name as name;

Thanks

Luigi

@freeart
Copy link
Author

freeart commented Sep 18, 2018

But why does it work in case of update/select queries?

@luigidellaquila
Copy link
Member

Good question, I think there is an ad-hoc management of this case, let me check, maybe we can do it also for the INSERT

Thanks

Luigi

@freeart
Copy link
Author

freeart commented Oct 4, 2018

Any news? I'm afraid to remove @rid in all cases because it can break other functionality.

@luigidellaquila
Copy link
Member

Hi @freeart

I'm pushing a fix now, it will be released with v 3.0.12

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