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

field aliases should require AS keyword

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Won't Fix
    • Major
    • 6.5.0
    • 6.5.0
    • query
    • None

    Description

      Currently you can alias a fields in two ways that I am aware of:

      select field1 a from default

      select field1 AS a from default

      However the first way of aliasing opens up the user to confusing issues if there is a typo in the query. For example:

      default bucket with documents like {"a":10, "b":20}

      query select a, b from default

      returns: [

      {"a":10,"b":20}

      ]

      If there was a missing comma typo in the query, the query becomes:
      select a b from default
      which thinks that I am aliasing a AS b and returns the following:
      [

      {"a":20}

      ]
      This type of error is pretty common and the debug is very confusing because not only do the wrong number of fields show up (implying that "b" field is missing in each document) but then the "a" fields looks like it has the wrong data.

      If we switch to just using AS for aliasing, this type of issue goes away and we would through an error for queries like select a b from default.

      Attachments

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

        Activity

          People

            keshav Keshav Murthy
            korrigan.clark Korrigan Clark (Inactive)
            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