You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2012/02/24 13:59:32 UTC

[6/8] git commit: cqlsh: tab-complete key alias for ALTER CF ALTER

cqlsh: tab-complete key alias for ALTER CF ALTER

patch by thepaul; reviewed by slebresne for CASSANDRA-3873


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/d64b9fff
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/d64b9fff
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/d64b9fff

Branch: refs/heads/trunk
Commit: d64b9fff57aac10a0078efd5121e84a11e808075
Parents: 5888fcd
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Fri Feb 24 11:20:14 2012 +0100
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Fri Feb 24 11:20:14 2012 +0100

----------------------------------------------------------------------
 bin/cqlsh                     |   12 ++++++------
 doc/cql/CQL.textile           |    2 +-
 pylib/cqlshlib/cqlhandling.py |    5 ++++-
 3 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/d64b9fff/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index f4773a7..5ea3bd5 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -1901,12 +1901,12 @@ class Shell(cmd.Cmd):
           ALTER COLUMNFAMILY addamsFamily ALTER lastKnownLocation TYPE uuid;
 
         ALTER COLUMNFAMILY ... ALTER changes the expected storage type for a
-        column. The column must already have a type in the column family
-        metadata. The column may or may not already exist in current rows-- but
-        be aware that no validation of existing data is done. The bytes stored
-        in values for that column will remain unchanged, and if existing data
-        is not deserializable according to the new type, this may cause your
-        CQL driver or interface to report errors.
+        column. The column must either be the key alias or already have a type
+        in the column family metadata. The column may or may not already exist
+        in current rows-- but be aware that no validation of existing data is
+        done. The bytes stored in values for that column will remain unchanged,
+        and if existing data is not deserializable according to the new type,
+        this may cause your CQL driver or interface to report errors.
         """
 
     def help_alter_add(self):

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d64b9fff/doc/cql/CQL.textile
----------------------------------------------------------------------
diff --git a/doc/cql/CQL.textile b/doc/cql/CQL.textile
index 4fd3d74..1cfe883 100644
--- a/doc/cql/CQL.textile
+++ b/doc/cql/CQL.textile
@@ -634,7 +634,7 @@ h3. Changing the type of a typed column
 bc(sample). 
 ALTER COLUMNFAMILY addamsFamily ALTER lastKnownLocation TYPE uuid;
 
-@ALTER COLUMNFAMILY ... ALTER@ changes the expected storage type for a column. The column must already have a type in the column family metadata. The column may or may not already exist in current rows-- but be aware that no validation of existing data is done. The bytes stored in values for that column will remain unchanged, and if existing data is not deserializable according to the new type, this may cause your CQL driver or interface to report errors.
+@ALTER COLUMNFAMILY ... ALTER@ changes the expected storage type for a column. The column must either be the key alias or already have a type in the column family metadata. The column may or may not already exist in current rows-- but be aware that no validation of existing data is done. The bytes stored in values for that column will remain unchanged, and if existing data is not deserializable according to the new type, this may cause your CQL driver or interface to report errors.
 
 h3. Adding a typed column
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d64b9fff/pylib/cqlshlib/cqlhandling.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/cqlhandling.py b/pylib/cqlshlib/cqlhandling.py
index e45fb45..d494a91 100644
--- a/pylib/cqlshlib/cqlhandling.py
+++ b/pylib/cqlshlib/cqlhandling.py
@@ -726,7 +726,10 @@ def alter_table_cf_completer(ctxt, cass):
 @completer_for('alterInstructions', 'existcol')
 def alter_table_col_completer(ctxt, cass):
     cfdef = cass.get_columnfamily(cql_dequote(ctxt.get_binding('cf')))
-    return map(maybe_cql_escape, [md.name for md in cfdef.column_metadata])
+    cols = [md.name for md in cfdef.column_metadata]
+    if cfdef.key_alias is not None:
+        cols.append(cfdef.key_alias)
+    return map(maybe_cql_escape, cols)
 
 explain_completion('alterInstructions', 'newcol', '<new_column_name>')