Details
-
Bug
-
Resolution: Fixed
-
Major
-
7.1.0
-
7.1.0-1824
-
Untriaged
-
1
-
Unknown
Description
Originally had filed this bug because I thought it should upload successfully, but I now think theres no reason we would ever want to allow the uploading of a n1ql syntax error, however the exact cause of this uploads failure is not quite clear, I know that it is because of a problem with the n1ql statement, but it simply says unexpected token default, whereas the issue is actually before default
ajaybhullar@SCML0613 ~ % curl -s -k -X POST http://172.23.104.110:8093/evaluator/v1/libraries/n1ql -u Administrator:password -H 'content-type: application/json' -d 'function syntax_error() { try{ var query = SELEC * FROM default WHERE lower(job_title) = "engineer"; var acc = []; for (const row of query) { acc.push(row); }}catch(err)
{throw "Syntax error at selec"} return acc;}'Error while compiling library. Cause:
compilation failed:
Exception: SyntaxError: Unexpected token 'default'
Location: functions/n1ql.js:1
Code: function syntax_error() { try{ var query = SELEC * FROM default WHERE lower(job_title) = "engineer"; var acc = []; for (const row of query) { acc.push(row); }}catch(err){throw "Syntax error at selec"}
return acc;}
SyntaxError: Unexpected token 'default'
another error message that is hard to follow is this one (first mentioned in the comments of this bug)
ajaybhullar@SCML0613 ~ % curl -s -k -X POST http://172.23.104.110:8093/evaluator/v1/libraries/n1ql2 -u Administrator:password -H 'content-type: application/json' -d 'function call_func1( x ) { var acc = []; if (x > 5) { x = x - 1; var query = EXECUTE FUNCTION call_func1( x ); for (const row of query) { acc.push(row);}} else { return acc; }}'
Error while compiling library. Cause:
compilation failed:
Exception: SyntaxError: Unexpected identifier
Location: functions/n1ql2.js:1
Code: function call_func1( x ) { var acc = []; if (x > 5) { x = x - 1; var query = EXECUTE FUNCTION call_func1( x ); for (const row of query) { acc.push(row);}} else { return acc; }}
SyntaxError: Unexpected identifier
in this specific case, the reason it is failing is because x needs to be parameterized as $x instead of just x
Attachments
Issue Links
- relates to
-
MB-49931 [UDF] Syntax error with query1 = DELETE FROM default
- Closed