arcadedb icon indicating copy to clipboard operation
arcadedb copied to clipboard

Logical AND operator in Javascript function prevents successful definition

Open DMCTowns opened this issue 8 months ago • 3 comments

Using a fresh demo install of Arcade DB (playwithdata):

docker run --rm -p 2480:2480 -p 2424:2424
           -e JAVA_OPTS="-Darcadedb.server.rootPassword=playwithdata -Darcadedb.server.defaultDatabases=Imported[root]{import:https://github.com/ArcadeData/arcadedb-datasets/raw/main/orientdb/OpenBeer.gz}"
           arcadedata/arcadedb:latest

Creating a function via the UI: http://localhost:2480/

This works:

DEFINE FUNCTION DataCollectionEntity.getMatchRating "return 1==1" PARAMETERS [a,b] LANGUAGE js

This doesn't work:

DEFINE FUNCTION DataCollectionEntity.getMatchRating "return 1==1 && 0==0" PARAMETERS [a,b] LANGUAGE js

and results in the server log:

SEVER [PostCommandHandler] <ArcadeDB_0> Error on command execution (PostCommandHandler): Error on definition of function 'getMatchRating'

The presence of the logical AND (&&) operator appears to prevent the function being defined

DMCTowns avatar Apr 14 '25 09:04 DMCTowns

Additionally, once this error occurs other function definition are prevented due to the former error.

gramian avatar Apr 14 '25 09:04 gramian

Until fixed, converting AND to OR, A && B becomes !(!A || !B) could be a workaround, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND#converting_and_to_or

gramian avatar Apr 14 '25 09:04 gramian

It must be an issue with Studio and encoding. I suspect the && is escaped wrongly.

lvca avatar Apr 14 '25 12:04 lvca

@DMCTowns it should be ok now

robfrank avatar Sep 22 '25 15:09 robfrank