Uploaded image for project: 'Couchbase node.js Client Library'
  1. Couchbase node.js Client Library
  2. JSCBC-682

Named N1QL parameters cause LCB error

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.0.1
    • 3.0.0
    • None
    • None
    • Node SDK 3.0.0
    • 1

    Description

      N1QL queries with named parameters are rejected when they reach LCB, as LCB expected an array but got a JSON object, as produced here. LCB does have code to handle the JSON so the query is likely being passed through to the wrong function / with the wrong flags etc.

      Code to reproduce:

      const couchbase = require('couchbase')
      const cluster = new couchbase.Cluster('couchbase://10.112.195.103,10.112.195.104/', {username: 'Administrator', password: 'password'})
      // Need to open a bucket to be able to run queries (thought this had changed in 3.0?)
      const bucket = cluster.bucket('travel-sample')
      // Any query with named parameters should do
      const QUERY = "SELECT country, name, icao FROM `travel-sample` WHERE country = $country AND type = `airline` ORDER BY icao LIMIT 15"
      cluster.query(QUERY, {parameters: {'country': 'United Kingdom'}}, (err, rows) => {
          console.log(rows)
          console.log(err)
      })
      

       Output:

      { [Error: LCB_ERR_HTTP (1053): HTTP Operation failed. Inspect status code for details]
        code: 1053,
        ctxtype: 'query',
        first_error_code: 1070,
        first_error_message: 'args has to be of type array',
        statement:
         'SELECT country, name, icao FROM `travel-sample` WHERE country = $country AND type = `airline` ORDER BY icao LIMIT 15',
        client_context_id: 'fdd478483bf90607',
        parameters: '',
        http_response_code: 400,
        http_response_body: '' }
      

      Attachments

        Issue Links

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

          Activity

            People

              michael.reiche Michael Reiche
              daniel.roberts Daniel Roberts (Inactive)
              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