Updated Branches: refs/heads/trunk db9bc6929 -> 0bff97a2c
Backport CASSANDRA-6196 to 1.2 patch by Mikhail Stepura; reviewed by Aleksey Yeschenko for CASSANDRA-6196 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/12413ad1 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/12413ad1 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/12413ad1 Branch: refs/heads/trunk Commit: 12413ad1f848aacb3314d279fb4db7e2b293d066 Parents: a9b403e Author: Aleksey Yeschenko <alek...@apache.org> Authored: Tue Oct 22 14:21:38 2013 +0800 Committer: Aleksey Yeschenko <alek...@apache.org> Committed: Tue Oct 22 14:22:13 2013 +0800 ---------------------------------------------------------------------- CHANGES.txt | 1 + bin/cqlsh | 2 +- pylib/cqlshlib/cql3handling.py | 88 +------------------------------------ 3 files changed, 3 insertions(+), 88 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/12413ad1/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 117a200..4d07d78 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,7 @@ 1.2.12 * (Hadoop) Require CFRR batchSize to be at least 2 (CASSANDRA-6114) * Fix altering column types (CASSANDRA-6185) + * cqlsh: fix CREATE/ALTER WITH completion (CASSANDRA-6196) 1.2.11 http://git-wip-us.apache.org/repos/asf/cassandra/blob/12413ad1/bin/cqlsh ---------------------------------------------------------------------- diff --git a/bin/cqlsh b/bin/cqlsh index 64e9b6f..5ccab3d 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -32,7 +32,7 @@ exit 1 from __future__ import with_statement description = "CQL Shell for Apache Cassandra" -version = "3.1.7" +version = "3.1.8" from StringIO import StringIO from itertools import groupby http://git-wip-us.apache.org/repos/asf/cassandra/blob/12413ad1/pylib/cqlshlib/cql3handling.py ---------------------------------------------------------------------- diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py index c5b449f..b9265fd 100644 --- a/pylib/cqlshlib/cql3handling.py +++ b/pylib/cqlshlib/cql3handling.py @@ -1017,92 +1017,6 @@ def create_ks_wat_completer(ctxt, cass): return ['KEYSPACE'] return ['KEYSPACE', 'SCHEMA'] -@completer_for('oldPropSpec', 'optname') -def create_ks_opt_completer(ctxt, cass): - exist_opts = ctxt.get_binding('optname', ()) - try: - stratopt = exist_opts.index('strategy_class') - except ValueError: - return ['strategy_class ='] - vals = ctxt.get_binding('optval') - stratclass = dequote_value(vals[stratopt]) - if stratclass in CqlRuleSet.replication_factor_strategies: - return ['strategy_options:replication_factor ='] - return [Hint('<strategy_option_name>')] - -@completer_for('oldPropSpec', 'optval') -def create_ks_optval_completer(ctxt, cass): - exist_opts = ctxt.get_binding('optname', (None,)) - if exist_opts[-1] == 'strategy_class': - return map(escape_value, CqlRuleSet.replication_strategies) - return [Hint('<option_value>')] - -@completer_for('newPropSpec', 'propname') -def keyspace_properties_option_name_completer(ctxt, cass): - optsseen = ctxt.get_binding('propname', ()) - if 'replication' not in optsseen: - return ['replication'] - return ["durable_writes"] - -@completer_for('propertyValue', 'propsimpleval') -def property_value_completer(ctxt, cass): - optname = ctxt.get_binding('propname')[-1] - if optname == 'durable_writes': - return ["'true'", "'false'"] - if optname == 'replication': - return ["{'class': '"] - return () - -@completer_for('propertyValue', 'propmapkey') -def keyspace_properties_map_key_completer(ctxt, cass): - optname = ctxt.get_binding('propname')[-1] - if optname != 'replication': - return () - keysseen = map(dequote_value, ctxt.get_binding('propmapkey', ())) - valsseen = map(dequote_value, ctxt.get_binding('propmapval', ())) - for k, v in zip(keysseen, valsseen): - if k == 'class': - repclass = v - break - else: - return ["'class'"] - if repclass in CqlRuleSet.replication_factor_strategies: - opts = set(('replication_factor',)) - elif repclass == 'NetworkTopologyStrategy': - return [Hint('<dc_name>')] - return map(escape_value, opts.difference(keysseen)) - -@completer_for('propertyValue', 'propmapval') -def keyspace_properties_map_value_completer(ctxt, cass): - optname = ctxt.get_binding('propname')[-1] - if optname != 'replication': - return () - currentkey = dequote_value(ctxt.get_binding('propmapkey')[-1]) - if currentkey == 'class': - return map(escape_value, CqlRuleSet.replication_strategies) - return [Hint('<value>')] - -@completer_for('propertyValue', 'ender') -def keyspace_properties_map_ender_completer(ctxt, cass): - optname = ctxt.get_binding('propname')[-1] - if optname != 'replication': - return [','] - keysseen = map(dequote_value, ctxt.get_binding('propmapkey', ())) - valsseen = map(dequote_value, ctxt.get_binding('propmapval', ())) - for k, v in zip(keysseen, valsseen): - if k == 'class': - repclass = v - break - else: - return [','] - if repclass in CqlRuleSet.replication_factor_strategies: - opts = set(('replication_factor',)) - if 'replication_factor' not in keysseen: - return [','] - if repclass == 'NetworkTopologyStrategy' and len(keysseen) == 1: - return [','] - return ['}'] - syntax_rules += r''' <createColumnFamilyStatement> ::= "CREATE" wat=( "COLUMNFAMILY" | "TABLE" ) ( ks=<nonSystemKeyspaceName> dot="." )? cf=<cfOrKsName> @@ -1228,7 +1142,7 @@ def drop_index_completer(ctxt, cass): return map(maybe_escape_name, cass.get_index_names()) syntax_rules += r''' -<alterTableStatement> ::= "ALTER" ( "COLUMNFAMILY" | "TABLE" ) cf=<columnFamilyName> +<alterTableStatement> ::= "ALTER" wat=( "COLUMNFAMILY" | "TABLE" ) cf=<columnFamilyName> <alterInstructions> ; <alterInstructions> ::= "ALTER" existcol=<cident> "TYPE" <storageType>