Logical AND operator in Javascript function prevents successful definition
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
Additionally, once this error occurs other function definition are prevented due to the former error.
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
It must be an issue with Studio and encoding. I suspect the && is escaped wrongly.
@DMCTowns it should be ok now