cqlsh: fix KEY pseudocolumn escaping when describing Thrift tables; patch by Aleksey Yeschenko, reviewed by Brandon Williams for CASSANDRA-4955
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ab5c06fd Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ab5c06fd Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ab5c06fd Branch: refs/heads/cassandra-1.2 Commit: ab5c06fd7edbbcb97c0d2684951a6c0026e4182d Parents: 1ef67f4 Author: Aleksey Yeschenko <alek...@apache.org> Authored: Thu Nov 29 22:49:22 2012 +0300 Committer: Aleksey Yeschenko <alek...@apache.org> Committed: Thu Nov 29 22:49:22 2012 +0300 ---------------------------------------------------------------------- CHANGES.txt | 2 ++ pylib/cqlshlib/cql3handling.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/ab5c06fd/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 8bfcc06..fa8bafe 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -38,6 +38,8 @@ Merged from 1.1: * Allow static CF definition with compact storage (CASSANDRA-4910) * Fix endless loop/compaction of schema_* CFs due to broken timestamps (CASSANDRA-4880) * Fix 'wrong class type' assertion in CounterColumn (CASSANDRA-4976) + * clqsh: fix KEY pseudocolumn escaping when describing Thrift tables + in CQL3 mode (CASSANDRA-4955) 1.2-beta2 http://git-wip-us.apache.org/repos/asf/cassandra/blob/ab5c06fd/pylib/cqlshlib/cql3handling.py ---------------------------------------------------------------------- diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py index 254e62a..cbb2700 100644 --- a/pylib/cqlshlib/cql3handling.py +++ b/pylib/cqlshlib/cql3handling.py @@ -51,6 +51,10 @@ class Cql3ParsingRuleSet(CqlParsingRuleSet): 'token', 'writetime', 'map', 'list', 'to' )) + unreserved_keywords = set(( + 'key', 'clustering', 'ttl', 'compact', 'storage', 'type', 'values' + )) + columnfamily_options = ( # (CQL option name, Thrift option name (or None if same)) ('comment', None), @@ -146,7 +150,9 @@ class Cql3ParsingRuleSet(CqlParsingRuleSet): @classmethod def is_valid_cql3_name(cls, s): - if s is None or s.lower() in cls.keywords: + if s is None: + return False + if s.lower() in cls.keywords - cls.unreserved_keywords: return False return cls.valid_cql3_word_re.match(s) is not None @@ -1418,7 +1424,7 @@ class CqlTableDef: if cf.key_alias: cf.key_aliases = [cf.key_alias.decode('ascii')] else: - cf.key_aliases = [u'KEY'] + cf.key_aliases = [u'key'] cf.partition_key_components = cf.key_aliases cf.primary_key_components = cf.key_aliases + list(cf.column_aliases) cf.partition_key_validator = lookup_casstype(cf.key_validator)