-
Notifications
You must be signed in to change notification settings - Fork 67
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
Newline in batch CREATE FUNCTION causes lexical error in OrientDB #444
Comments
A significantly better workaround is to not use the Make sure to escape backslashes, pipes and double quotes from the code. const statement = `INSERT INTO OFunction CONTENT {
"name": "someFunction",
"code": "${someFunctionCodeString.replace(/\\|"/g, (m) => '\\'+m)}",
"parameters": ["param1","param2"],
"idempotent": true,
"language": "JAVASCRIPT"
};`; As an idea for future development: the above is done so functions can be kept in their own Having everything about the function in one file is a nice pattern for organizing custom functions, and it would be great if OrientJS included a function manager that did this out-of-the-box. |
OrientJS version: 3.0.11
When using
CREATE FUNCTION
insession.batch()
, having a newline in the function body causes a lexical error in OrientDB.The same
CREATE FUNCTION
statements work from Functions Management in Studio, although that way the functions get saved without any newlines.Working example with everything on one line:
But if the code is split into multiple lines...
... it produces an error:
{"name":"OrientDB.ConnectionError [10]","code":10,"message":"Cannot select the server","data":{}}
Stack trace from OrientDB logs:
Workaround
As a workaround, the newlines can be escaped, but this can be a burden for larger scripts:
These examples use JavaScript functions, but the problem is the same when creating functions with
LANGUAGE SQL
.The text was updated successfully, but these errors were encountered: