You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I opened a StackOverflow ticket on this recently but I believe it is actually a bug.
OrientDB Version: 3.0.0
Java Version: 1.8.0_171
OS: Ubuntu 16.04
Expected behavior
$3.size() should be greater than 0 for both of the following scripts
LET $1 = SELECT expand(bothE(Begets)) FROM Creature WHERE uniquename='hildigrimTook';
LET $2 = SELECT expand(bothE(Begets)) FROM Creature WHERE uniquename='adalgrimTook';
LET $3 = SELECT INTERSECT($1, $2).size();
LET $4 = CREATE EDGE Begets FROM (SELECT FROM Creature WHERE uniquename='hildigrimTook') TO (SELECT FROM Creature WHERE uniquename='adalgrimTook');
SELECT $3.size();
LET $1 = SELECT expand(bothE(Begets)) FROM Creature WHERE uniquename='hildigrimTook';
LET $2 = SELECT expand(bothE(Begets)) FROM Creature WHERE uniquename='adalgrimTook';
LET $3 = SELECT INTERSECT($1, $2).size();
LET $4 = CREATE EDGE Begets FROM (SELECT FROM Creature WHERE uniquename='hildigrimTook') TO (SELECT FROM Creature WHERE uniquename='adalgrimTook');
IF($3.size() > 0 {
return 'Edge already exists'
}
IF($3.size() == 0 {
return $4;
}
Actual behavior
Calling $3.size() is 0 when called from inside of an IF() statement, but > 0 when called from a SELECT, so $4 is called every time and creates duplicate edges.
Steps to reproduce
The following creates a duplicate edge instead of correctly reading $3.size() and returning 'Edge already exists'.
LET $1 = SELECT expand(bothE(Begets)) FROM Creature WHERE uniquename='hildigrimTook';
LET $2 = SELECT expand(bothE(Begets)) FROM Creature WHERE uniquename='adalgrimTook';
LET $3 = SELECT INTERSECT($1, $2).size();
LET $4 = CREATE EDGE Begets FROM (SELECT FROM Creature WHERE uniquename='hildigrimTook') TO (SELECT FROM Creature WHERE uniquename='adalgrimTook');
IF($3.size() > 0 {
return 'Edge already exists'
}
IF($3.size() == 0 {
return $4;
}
The text was updated successfully, but these errors were encountered:
I pushed a fix to develop branch, the new snapshot is already available.
Just please consider that the LET statements are evaluated early, so in your case the edge is created anyway.
What you probably need is something as follows:
LET $1 = SELECT expand(bothE(Begets)) FROM Creature WHERE uniquename='hildigrimTook';
LET $2 = SELECT expand(bothE(Begets)) FROM Creature WHERE uniquename='adalgrimTook';
LET $3 = SELECT INTERSECT($1, $2).size();
uniquename='hildigrimTook') TO (SELECT FROM Creature WHERE uniquename='adalgrimTook');
IF($3.size() > 0 {
return 'Edge already exists'
}
IF($3.size() == 0 {
LET $4 = CREATE EDGE Begets FROM (SELECT FROM Creature WHERE
return $4;
}
I opened a StackOverflow ticket on this recently but I believe it is actually a bug.
OrientDB Version: 3.0.0
Java Version: 1.8.0_171
OS: Ubuntu 16.04
Expected behavior
$3.size() should be greater than 0 for both of the following scripts
Actual behavior
Calling
$3.size()
is 0 when called from inside of anIF()
statement, but > 0 when called from aSELECT
, so $4 is called every time and creates duplicate edges.Steps to reproduce
The following creates a duplicate edge instead of correctly reading $3.size() and returning 'Edge already exists'.
The text was updated successfully, but these errors were encountered: