Functions in Studio stopped working

43 views
Skip to first unread message

Ricardo A. Pasquini

unread,
Nov 24, 2015, 8:03:46 PM11/24/15
to OrientDB
Dear all,
Hope you can help me with an error message that appears when executing functions from the Functions' Manager in Studio.
In the last days I have written several functions in Javascript that I was executing nicely from Studio, but suddently it stopped working.
No matter which Function I execute, I am obtaining exactly the same "Bad Request error". The error message is showing some previous commands I ran from the Browse tab, with no reference at all to the actual Function.
In order to show the problem, I wrote the simplest function as an example: 




Here is the detail of the error, which include some previous querys I ran from the Browse tab. 

{
    "errors": [
        {
            "code": 400,
            "reason": "Bad request",
            "content": "ScriptManager: error <eval>:58:7 Expected ; but found yearmonth\r\nselect yearmonth.substring(0, 4), yearmonth.right(2) from yearmonth\r\n       ^ in <eval> at line number 58 at column number 7.\nFunction randomedges(nombreclase,nombreclaseedges):\n\n  53: \n  54: //selection of months\n  55: var text=\"insert into yearmonth from select from (select from (select distinct(createdat1.format('yyyy-MM')) as yearmonth from Rolein) order by yearmonth)\";\n  56: var yearmonth=g.command(\"sql\",text);\n  57: \n  58: >>> select yearmonth.substring(0, 4), yearmonth.right(2) from yearmonth\n  59: \n  60: g.command(\"sql\",\"UPDATE yearmonth SET year=yearmonth.substring(0, 4)\")\n  61: g.command(\"sql\",\"UPDATE yearmonth SET month=yearmonth.right(2)\")\n  62: \n  63: }\n"
        }
    ]
}


If the problem is somewhat related with the ScriptManager, is there a way to reset it in someway? I have already restarted my browser, also tried by restarting the server, but the problem remains.
Thanks in advance,
Ricardo

Kyle

unread,
Nov 24, 2015, 8:30:31 PM11/24/15
to OrientDB
I think one error in a {sql, javascript, groovy} function causes an error in all functions in the same language.

The "previous commands I ran from the Browse tab" part is perplexing but here is what I would do for debugging:

1) test a non-javascript function to see if it works.
2) 
comment out all the javascript functions
check if a new simple function works.
if it works, uncomment the javascript functions one by one to find the one with the error.


hope this helps.

Ricardo A. Pasquini

unread,
Nov 24, 2015, 10:01:52 PM11/24/15
to OrientDB
Thanks very much Kyle! It worked! As I could debug, the problem arised because of a non-closed bracket in an IF expression from another function. This seems consistent with your explanation that an error in a function returned an error in another one. Perhaps because the IF statement was not resolved. 
Anyway your hint helped a lot!
Many thanks and regards
Ricardo 
Reply all
Reply to author
Forward
0 new messages