Uploaded image for project: 'Couchbase Documentation'
  1. Couchbase Documentation
  2. DOC-10221

N1QL tutorial query context syntax incorrect

    XMLWordPrintable

Details

    Description

      The "Run your first N1QL query" tutorial has the below line:

      \SET -query_context 'travel-sample.inventory';
      

      But setting it in CBQ and then running a query fails with a keyspace not found error:

      cbq> \SET -query_context 'travel-sample.inventory';
      cbq> SELECT a.country FROM airline a WHERE a.name = "Excel Airways";
      {
          "requestID": "83a0a47b-5133-4b60-bf35-85bc0433984e",
          "errors": [
              {
                  "code": 12003,
                  "msg": "Keyspace not found in CB datastore: default:'travel-sample - cause: No bucket named 'travel-sample"
              }
          ],
          "status": "fatal",
          "metrics": {
              "elapsedTime": "23.770629ms",
              "executionTime": "23.65818ms",
              "resultCount": 0,
              "resultSize": 0,
              "serviceLoad": 4,
              "errorCount": 1
          }
      }
      

      The correct syntax doesn't have the apostrophes:

      cbq> \SET -query_context travel-sample.inventory;
      cbq> SELECT a.country FROM airline a WHERE a.name = "Excel Airways";
      {
          "requestID": "ef4df5b2-fdbf-4a50-a1d3-7ec94ea92f74",
          "signature": {
              "country": "json"
          },
          "results": [
          {
              "country": "United Kingdom"
          }
          ],
          "status": "success",
          "metrics": {
              "elapsedTime": "15.97345ms",
              "executionTime": "15.861355ms",
              "resultCount": 1,
              "resultSize": 43,
              "serviceLoad": 4
          }
      }
      

      Reporter: Daniel Thole
      E-mail: daniel.thole@couchbase.com

      Attachments

        Activity

          People

            simon.dew Simon Dew
            daniel.thole Daniel Thole (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty