Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-2939

CQL regex to match column family in query

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • None
    • None
    • Python CQL

    • Low

    Description

      In the file cursor.py (https://svn.apache.org/repos/asf/cassandra/drivers/py/cql/cursor.py)

      Line 37: _cfamily_re = re.compile("\s*SELECT\s+.+\s+FROM\s+[\']?(\w+)", re.I | re.M)

      The Regex will improperly match anything after the word 'from' even if it is in the WHERE clause

      I believe the fix is:

      _cfamily_re = re.compile("\s*SELECT\s+.+?\s+FROM\s+[\']?(\w+)", re.I | re.M)

      Added the ? so the regex is not so greedy

      use this query to reproduce the results:

      SELECT key FROM column_family WHERE key = 'break from chores'"

      Attachments

        1. 2939-test.txt
          1.0 kB
          Tom Hobbs
        2. 2939.txt
          0.5 kB
          Tom Hobbs

        Activity

          People

            bcvisin Blake Visin
            bcvisin Blake Visin
            Blake Visin
            Tom Hobbs
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: