arcadedb icon indicating copy to clipboard operation
arcadedb copied to clipboard

Reference memory java $ unable to do math operators. Resulting in ref java memory

Open eisenhaus335 opened this issue 1 year ago • 4 comments

ArcadeDB Version:

"version": "24.1.1 (build 5ecb28ea54dc3e109336645e64794e5eb5ca8ddf/1709313171626/main)"

OS and JDK Version:

Linux 5.15.133.1-microsoft-standard-WSL2 - OpenJDK 64-Bit Server VM 11.0.22

Expected behavior

Doing operators into $ ref memory should been work correctly

Actual behavior

The sql result show is weird java ref memory "com.arcadedb.query.sql.executor.InternalResultSet@52806f961"

Steps to reproduce

begin; let max = SELECT max(seqid) FROM Invoice; let invoice = CREATE VERTEX Invoice (seqid) VALUES ($max + 1); commit retry 100; return $invoice;

eisenhaus335 avatar Sep 16 '24 07:09 eisenhaus335

Reproduced, using:

CREATE VERTEX TYPE Invoice;
CREATE PROPERTY Invoice.seqid INTEGER;

gramian avatar Sep 16 '24 07:09 gramian

Here is a workaround:

LET $maxid = SELECT 1 + max(seqid) AS id FROM Invoice;
LET $invoice = INSERT INTO Invoice SET seqid = $maxid.id[0];
RETURN $invoice;

Nonetheless, the above behavior needs to be fixed.

WRT the original code, this works:

begin;
let $maxid = SELECT max(seqid) AS id FROM Invoice;
let $invoice = CREATE VERTEX Invoice (seqid) VALUES ($maxid.id[0] + 1);
commit retry 100;
return $invoice;

gramian avatar Sep 16 '24 07:09 gramian

This seems to reproduce the problem minimally:

let maxid = SELECT max(seqid) FROM Invoice;
return $maxid.asString()

gramian avatar Sep 16 '24 07:09 gramian

begin;
let max = SELECT max(seqid) as id FROM Invoice;
let invoice = CREATE VERTEX Invoice (seqid) VALUES ($max.id[0].asInteger() + 1);
commit retry 100;
return $invoice;

Using this also works. I think arcade query is quite particular that we stores reference as QuerySet. That we need to do with first()/x[0]. The bug seems resulted in query transaction are not converting the value or reference the value. So they operate with the object QuerySet. Maybe, there is no default or dynamic operators that deal between sqlscript expression lines when doing operators

eisenhaus335 avatar Sep 16 '24 07:09 eisenhaus335