Skip to content
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

Error in Function Parsing #5088

Closed
rakeshghodasara opened this issue Oct 9, 2015 · 2 comments
Closed

Error in Function Parsing #5088

rakeshghodasara opened this issue Oct 9, 2015 · 2 comments
Assignees
Labels

Comments

@rakeshghodasara
Copy link

I have issues with early vs late function evaluation.

I have a very small Javascript function that returns the local Id of the vertex. for eg : onlyid(#12:13) should return 13.

it is written as return(rid.split(":")[1]); This runs fine in the webUI.

however when I execute this from the query console as :
select onlyid(@Rid) from Class1;

I get error Error:

Error: com.orientechnologies.orient.core.exception.OStorageException: Error on executing command: sql.select onlyid(@Rid) from Class1

Error: java.lang.RuntimeException: com.orientechnologies.orient.core.command.script.OCommandScriptException: Error on parsing script at position #0: Error on execution of the script
Script: onlyid
------^

Error: com.orientechnologies.orient.core.command.script.OCommandScriptException: Error on parsing script at position #0: Error on execution of the script
Script: onlyid
------^

Error: com.orientechnologies.orient.core.exception.OStorageException: TypeError: #19:0 has no such function "split" in at line number 71

Error: com.orientechnologies.orient.core.exception.OStorageException: TypeError: #19:0 has no such function "split"

@luigidellaquila
Copy link
Member

Hi @rakeshghodasara

I think in WebUI it's receiving a string, so the split() works correctly.
When you execute it in a query, it will receive a RID object, that does not have a split method.
My suggestion is to change your function adding a toString(), eg.

 return (rid.toString().split(":")[1]); 

@luigidellaquila luigidellaquila self-assigned this Oct 12, 2015
@luigidellaquila luigidellaquila added this to the 2.2 milestone Oct 12, 2015
@rakeshghodasara
Copy link
Author

Got it to work with the explicit typecast. Thanks for you timely help luigi.

@lvca lvca added the question label Oct 12, 2015
@lvca lvca modified the milestone: 2.2.0-beta Dec 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants