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

[UDF] n1ql query with advise returns Unexpected identifier

    XMLWordPrintable

Details

    • Untriaged
    • 1
    • Unknown

    Description

      When trying to create a library with following JS code:

      function advisequery() {
        var iter =  advise select airportname from `travel-sample` where city = 'Grenoble';
        let acc = [];
        for (const row of iter) {
          acc.push(row.advice.adviseinfo.recommended_indexes);
        }
        return {'num_entries': acc.length, 'data': acc};
      } 

      we get error:

      Error while compiling library. Cause:
      compilation failed:
      Exception: SyntaxError: Unexpected identifier
      Location: functions/n1ql.js:1 
      Code: function advisequery() {    var iter =  advise N1QL('select airportname from `travel-sample` where city \u003D \'Grenoble\';', {});    let acc = [];    for (const row of iter) {            acc.push(row.advice.adviseinfo.recommended_indexes);    }    return {'num_entries': acc.length, 'data': acc};} 
      SyntaxError: Unexpected identifier 

      Workaround right now it explicitly wrap query with N1QL e.g.

          var iter =  N1QL("advise select airportname from `travel-sample` where city = 'Grenoble'", {}); 

      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:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty