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

Quoted strings with escaped characters inside parenthesis raise syntax error wrongly

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.0, 4.1.0, 4.5.0, 4.6.0, 5.0.0, 5.1.0, 6.5.0, 6.0.0, 5.5.0
    • 7.0.0
    • query
    • Untriaged
    • Unknown

    Description

      Queries like

      select x from default where contains(x, "
      "")

      fail with a syntax error (end of input)

      ('\'')

      fails too with invalid quoted string.

      Attachments

        Issue Links

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

          Activity

            Pierre Regazzoni, I'm not sure I follow... in the last example you have an opening single quote plus escaped literal single quote and no closing single quote, hence the syntax error.  You can use "'" (enclose the single quote in double quotes) or '''' (enclose an escaped-using-character-doubling single quote in single quotes).

            Remember there is a special case for single quotes where {{'' }}=={{ \'}} when inside a string.

             

            cbq> select '''';
            ...
            "results": [
             {
             "$1": "'"
            ...

             

            Donald.haggart Donald Haggart added a comment - Pierre Regazzoni , I'm not sure I follow... in the last example you have an opening single quote plus escaped literal single quote and no closing single quote, hence the syntax error.  You can use "'" (enclose the single quote in double quotes) or '''' (enclose an escaped-using-character-doubling single quote in single quotes). Remember there is a special case for single quotes where {{'' }} == {{ \'}} when inside a string.   cbq> select ''''; ... "results": [ { "$1": "'" ...  

            (FWIW, this escaping-by-doubling isn't my favourite but it was already in the code so... legacy...)

            Donald.haggart Donald Haggart added a comment - (FWIW, this escaping-by-doubling isn't my favourite but it was already in the code so... legacy...)

            ok i guess in the case of ''' syntax error is expected since we interpret as ' + escaped(') and we don't see the closing '

            pierre.regazzoni Pierre Regazzoni added a comment - ok i guess in the case of ''' syntax error is expected since we interpret as ' + escaped(') and we don't see the closing '

            closing per discussion

            pierre.regazzoni Pierre Regazzoni added a comment - closing per discussion

            Build couchbase-server-7.1.0-2173 contains query commit fbb422f with commit message:
            MB-50619 Revise MB-30176 fix.

            build-team Couchbase Build Team added a comment - Build couchbase-server-7.1.0-2173 contains query commit fbb422f with commit message: MB-50619 Revise MB-30176 fix.

            People

              Donald.haggart Donald Haggart
              marco.greco Marco Greco
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty