Skip to content

Conversation

@marcfisher
Copy link

Nice option to remove newlines from functions during createFn to make
it easier maintaining the functions.

Nice option to remove newlines from functions during createFn to make
it easier maintaining the functions.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 76.523% when pulling 27373ea on marcfisher:upstream into c824667 on orientechnologies:master.

1 similar comment
@coveralls
Copy link

coveralls commented Sep 20, 2016

Coverage Status

Coverage increased (+0.08%) to 76.523% when pulling 27373ea on marcfisher:upstream into c824667 on orientechnologies:master.

@wolf4ood
Copy link
Member

@marcfisher

why did you remove newline from functions?

In this way functions will not be really readable from Studio.

@marcfisher
Copy link
Author

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?

@wolf4ood
Copy link
Member

@marcfisher
Do you have a case that fails?
I didn't experience issue with newline

@marcfisher
Copy link
Author

marcfisher commented Sep 20, 2016

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants