Details
-
Bug
-
Resolution: Fixed
-
Major
-
7.1.0
-
None
-
Untriaged
-
1
-
Unknown
Description
If I do:
curl -v -X POST http://localhost:8093/evaluator/v1/li2 -u Administrator:password -H 'content-type: application/json' -d 'function insert1(){
var a = 1;
var query1 = SELECT 1;
var query2 = INSERT INTO test values(UUID(), {"fname": "John", "lname":"Doe"});
{color:#4472c4}}'
It works perfectly and I get:
- About to connect() to localhost port 8093 (#0)
- Trying ::1...
- Connected to localhost (::1) port 8093 (#0)
- Server auth using Basic with user 'Administrator'
> POST /evaluator/v1/libraries/kamudf2 HTTP/1.1
> Authorization: Basic QWRtaW5pc3RyYXRvcjpwYXNzd29yZA==
> User-Agent: curl/7.29.0
> Host: localhost:8093
> Accept: /
> content-type: application/json
> Content-Length: 136
>
- upload completely sent off: 136 out of 136 bytes
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Tue, 26 Oct 2021 01:14:26 GMT
< Content-Length: 14
<
- Connection #0 to host localhost left intact
But if write:
curl -v -X POST http://localhost:8093/evaluator/v1/libraries/kamudf2 -u Administrator:password -H 'content-type: application/json' -d 'function transinsert(){
var a = 1;
var query1 = BEGIN WORK;
var query2 = INSERT INTO test values(UUID(), {"fname": "John", "lname":"Doe"});
var query3 = COMMIT WORK;
{color:#4472c4}}'
I get:
- About to connect() to localhost port 8093 (#0)
- Trying ::1...
- Connected to localhost (::1) port 8093 (#0)
- Server auth using Basic with user 'Administrator'
> POST /evaluator/v1/libraries/kamudf2 HTTP/1.1
> Authorization: Basic QWRtaW5pc3RyYXRvcjpwYXNzd29yZA==
> User-Agent: curl/7.29.0
> Host: localhost:8093
> Accept: /
> content-type: application/json
> Content-Length: 164
>
- upload completely sent off: 164 out of 164 bytes
< HTTP/1.1 400 Bad Request
< Content-Type: application/json
< Date: Tue, 26 Oct 2021 01:18:43 GMT
< Content-Length: 206
<
Error while compiling library. Cause:
compilation failed:
Exception: SyntaxError: Unexpected identifier
Location: functions/kamudf2.js:3
Code: var query1 = BEGIN WORK;
SyntaxError: Unexpected identifier
- Connection #0 to host localhost left intact
I think you need to add: BEGIN WORK,COMMIT WORK, ROLLBACK WORK,START TRANSACTION,SAVEPOINT as acceptable N1QL statements in your code.