Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-49863

[UDF] SyntaxError: Unexpected identifier with insert with implicit name parameter

    XMLWordPrintable

Details

    • Bug
    • Resolution: User Error
    • Major
    • 7.1.0
    • 7.1.0
    • js-evaluator
    • 7.1.0-1801
    • Untriaged
    • 1
    • Unknown

    Description

      The following explicit syntax for insert with name parameters works:

      # cat insert1.js 
      function sp_insert(num) {
        try {
          var insert = N1QL('INSERT INTO default (KEY, VALUE) VALUES ("k002", {"num_col1": $num })', {"num": num});
          return "Succeeded.";
        } catch (error) {
          return "Failed: " + error;
        }
      }
       
      # curl -s -k -X POST http://172.23.104.91:8093/evaluator/v1/libraries/use_cases -u Administrator:password -H 'content-type: application/json' -d@insert1.js
       

      but following (implicit) fails:

      # cat insert2.js 
      function sp_insert(num) {
        try {
          var insert = INSERT INTO default (KEY, VALUE) VALUES ("k003", {"num_col1": $num });
          return "Succeeded.";
        } catch (error) {
          return "Failed: " + error;
        }
      }
       
      # curl -s -k -X POST http://172.23.104.91:8093/evaluator/v1/libraries/use_cases -u Administrator:password -H 'content-type: application/json' -d@insert2.js
      Error while compiling library. Cause:
      compilation failed:
      Exception: SyntaxError: Unexpected identifier
      Location: functions/use_cases.js:1 
      Code: function sp_insert(num) {  try {    var insert = INSERT INTO default (KEY, VALUE) VALUES ("k003", {"num_col1": $num });    return "Succeeded.";  } catch (error) {    return "Failed: " + error;  }}
      SyntaxError: Unexpected identifier
       
       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            pierre.regazzoni Pierre Regazzoni
            pierre.regazzoni Pierre Regazzoni
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty