Remove newlines for createFn
Nice option to remove newlines from functions during createFn to make it easier maintaining the functions.
Coverage increased (+0.08%) to 76.523% when pulling 27373eaea7428aac1ffed7fd88ae9e1de87fa8c7 on marcfisher:upstream into c8246679a710f0f2014fca014a2e9ad26aad762b on orientechnologies:master.
Coverage increased (+0.08%) to 76.523% when pulling 27373eaea7428aac1ffed7fd88ae9e1de87fa8c7 on marcfisher:upstream into c8246679a710f0f2014fca014a2e9ad26aad762b on orientechnologies:master.
@marcfisher
why did you remove newline from functions?
In this way functions will not be really readable from Studio.
Sending a javascript function through createFn currently throws an error when it contains newlines. Be nice to have at least the option to have them removed instead of reproducing the same logic with parse-function in the application code. or is this an orientDB issue itself not accepting the newlines in the functions?
@marcfisher Do you have a case that fails? I didn't experience issue with newline
Sure.
All I am doing in the code is importing a file which has a map of keys to functions. I iterate over it and call db.createFn(key, map[key]) basically for each. They all fail, I've added an example function below as well as the stack trace which I think is the meaningful part. With that newline removed adding into orientjs there is no issue, without it add any function with multiple lines always fails.
function(_Vertex, _Content) { try { var db = orient.getGraph(); var commandsql = "CREATE VERTEX " + _Vertex + " CONTENT " + _Content; var results = db.command("sql", commandsql); } catch(err) { return err; } db.commit(); return results; }
Stack Trace: nhandled rejection OrientDB.RequestError: Lexical error at line 1, column 37. Encountered: "\n" (10), after : ""try {" at child.Operation.parseError (/Users/marcfisher/Projects/liongard/roar-base/backend/node_modules/orientjs/lib/transport/binary/protocol33/operation.js:864:13) at child.Operation.consume (/Users/marcfisher/Projects/liongard/roar-base/backend/node_modules/orientjs/lib/transport/binary/protocol33/operation.js:455:35) at Connection.process (/Users/marcfisher/Projects/liongard/roar-base/backend/node_modules/orientjs/lib/transport/binary/connection.js:399:17) at Connection.handleSocketData (/Users/marcfisher/Projects/liongard/roar-base/backend/node_modules/orientjs/lib/transport/binary/connection.js:290:20) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) ...
BTW are you primary maintainer of OrientJS currently?