cqlsh: fix DESCRIBE for 1.1 cfs in CQL3 patch by Aleksey Yeschenko; reviewed by Brandon Williams for CASSANDRA-5101
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/3411adfd Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/3411adfd Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/3411adfd Branch: refs/heads/trunk Commit: 3411adfdd27fc7ff505e473e072a636a536d2217 Parents: 0b0a00d Author: Aleksey Yeschenko <alek...@apache.org> Authored: Fri Jan 4 19:20:45 2013 +0300 Committer: Aleksey Yeschenko <alek...@apache.org> Committed: Fri Jan 4 19:24:04 2013 +0300 ---------------------------------------------------------------------- CHANGES.txt | 1 + pylib/cqlshlib/cql3handling.py | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/3411adfd/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 41aab18..a51864c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -18,6 +18,7 @@ * Add SSL support for the binary protocol (CASSANDRA-5031) * Allow non-schema system ks modification for shuffle to work (CASSANDRA-5097) * cqlsh: Add default limit to SELECT statements (CASSANDRA-4972) + * cqlsh: fix DESCRIBE for 1.1 cfs in CQL3 (CASSANDRA-5101) 1.2.0 http://git-wip-us.apache.org/repos/asf/cassandra/blob/3411adfd/pylib/cqlshlib/cql3handling.py ---------------------------------------------------------------------- diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py index 2c07434..f620d28 100644 --- a/pylib/cqlshlib/cql3handling.py +++ b/pylib/cqlshlib/cql3handling.py @@ -38,7 +38,7 @@ class UnexpectedTableStructure(UserWarning): def __str__(self): return 'Unexpected table structure; may not translate correctly to CQL. ' + self.msg -SYSTEM_KEYSPACES = ('system', 'system_traces') +SYSTEM_KEYSPACES = ('system', 'system_traces', 'system_auth') class Cql3ParsingRuleSet(CqlParsingRuleSet): keywords = set(( @@ -1441,7 +1441,11 @@ class CqlTableDef: cf.keyspace = ksname for attr in cls.json_attrs: try: - setattr(cf, attr, json.loads(getattr(cf, attr))) + val = getattr(cf, attr) + # cfs created in 1.1 may not have key_aliases defined + if attr == 'key_aliases' and val is None: + val = '[]' + setattr(cf, attr, json.loads(val)) except AttributeError: pass cf.partition_key_validator = lookup_casstype(cf.key_validator) @@ -1472,7 +1476,7 @@ class CqlTableDef: def get_key_aliases(self): if not issubclass(self.partition_key_validator, CompositeType): - return self.key_aliases or [u'key'] + return self.key_aliases or (self.key_alias and [self.key_alias]) or [u'key'] expected = len(self.partition_key_validator.subtypes) # key, key2, key3, ..., keyN aliases = [u'key'] + [ u'key' + str(i) for i in range(2, expected + 1) ]