QueryBuilder.quote applies duplicate double quotes for some valid identifiers.

Description

QueryBuilder.quote can apply duplicate double quotes to valid identifiers. For example 'foo.bar', 'foo bar', 'foo!bar' are all valid column names.

The CQL Spec defines a quoted identifier as:

...quoted identifiers [are] defined by enclosing an arbitrary sequence of characters in double-quotes(")

QueryBuilder.quote makes use of Utils.appendName. Since its possible for a valid quoted identifier to not match cnamePattern even though it is a valid identifier, it gets quoted twice.

Given that quoted-identifiers are an arbitrary sequence of characters, should consider quoting any sequence of characters given to QueryBuilder.quote.


Fix: changed quote to blindly apply quotes to its input. See discussion on pull request for more details.

Environment

None

Pull Requests

None

Activity

Show:
Kevin Gallardo
May 28, 2015, 5:20 PM

The solution here as discussed with Andrew Tolbert, would be to extend cnamePattern to match more valid identifiers. Since indeed when using a valid quoted identifier in quote() , it will apply extra double quotes. Hence, cnamePattern will be a combination of quoted and unquoted identifiers.

Fixed

Assignee

Kevin Gallardo

Reporter

Andy Tolbert

Labels

None

PM Priority

None

Reproduced in

2.0.9.2

Affects versions

Fix versions

Pull Request

None

Doc Impact

None

Size

None

External issue ID

None

External issue ID

None

Components

Priority

Major