cqlsh: don't suggest CL.ANY on selects
Patch by paul cannon, reviewed by brandonwilliams for CASSANDRA-4074


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

Branch: refs/heads/cassandra-1.1
Commit: 9f32efa727e4298784231a8ebb2d7e3f48630fd0
Parents: 7f6cc5e
Author: Brandon Williams <[email protected]>
Authored: Sat Jul 14 16:21:27 2012 -0500
Committer: Brandon Williams <[email protected]>
Committed: Sat Jul 14 16:21:27 2012 -0500

----------------------------------------------------------------------
 pylib/cqlshlib/cql3handling.py |   28 ++++++++++++++++++----------
 pylib/cqlshlib/cqlhandling.py  |    6 +++++-
 2 files changed, 23 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9f32efa7/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py
index 1628c66..5099322 100644
--- a/pylib/cqlshlib/cql3handling.py
+++ b/pylib/cqlshlib/cql3handling.py
@@ -205,15 +205,15 @@ JUNK ::= /([ 
\t\r\f\v]+|(--|[/][/])[^\n\r]*([\n\r]|$)|[/][*].*?[*][/])/ ;
                           | <alterTableStatement>
                           ;
 
-<consistencylevel> ::= <K_ONE>
-                     | <K_QUORUM>
-                     | <K_ALL>
-                     | <K_ANY>
-                     | <K_LOCAL_QUORUM>
-                     | <K_EACH_QUORUM>
-                     | <K_TWO>
-                     | <K_THREE>
-                     ;
+<consistencylevel> ::= cl=( <K_ONE>
+                          | <K_QUORUM>
+                          | <K_ALL>
+                          | <K_ANY>
+                          | <K_LOCAL_QUORUM>
+                          | <K_EACH_QUORUM>
+                          | <K_TWO>
+                          | <K_THREE> )
+                          ;
 
 <storageType> ::= typename=( <identifier> | <stringLiteral> ) ;
 
@@ -239,6 +239,10 @@ JUNK ::= /([ 
\t\r\f\v]+|(--|[/][/])[^\n\r]*([\n\r]|$)|[/][*].*?[*][/])/ ;
                       ;
 '''
 
+@completer_for('consistencylevel', 'cl')
+def consistencylevel_cl_completer(ctxt, cass):
+    return CqlRuleSet.consistency_levels
+
 @completer_for('extendedTerm', 'token')
 def token_word_completer(ctxt, cass):
     return ['TOKEN(']
@@ -285,7 +289,7 @@ syntax_rules += r'''
                  ;
 <selectStatement> ::= "SELECT" <selectClause>
                         "FROM" cf=<columnFamilyName>
-                          ("USING" "CONSISTENCY" <consistencylevel>)?
+                          ("USING" "CONSISTENCY" selcl=<consistencylevel>)?
                           ("WHERE" <whereClause>)?
                           ("ORDER" "BY" <orderByClause> ( "," <orderByClause> 
)* )?
                           ("LIMIT" <wholenumber>)?
@@ -304,6 +308,10 @@ syntax_rules += r'''
                   ;
 '''
 
+@completer_for('selectStatement', 'selcl')
+def select_statement_consistencylevel(ctxt, cass):
+    return [cl for cl in CqlRuleSet.consistency_levels if cl != 'ANY']
+
 @completer_for('orderByClause', 'ordercol')
 def select_order_column_completer(ctxt, cass):
     prev_order_cols = ctxt.get_binding('ordercol', ())

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9f32efa7/pylib/cqlshlib/cqlhandling.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/cqlhandling.py b/pylib/cqlshlib/cqlhandling.py
index aa29c60..715f6f9 100644
--- a/pylib/cqlshlib/cqlhandling.py
+++ b/pylib/cqlshlib/cqlhandling.py
@@ -576,7 +576,7 @@ syntax_rules += r'''
                  ;
 <selectStatement> ::= "SELECT" <whatToSelect>
                         "FROM" cf=<columnFamilyName>
-                          ("USING" "CONSISTENCY" <consistencylevel>)?
+                          ("USING" "CONSISTENCY" selcl=<consistencylevel>)?
                           ("WHERE" <selectWhereClause>)?
                           ("LIMIT" <integer>)?
                     ;
@@ -592,6 +592,10 @@ syntax_rules += r'''
                  ;
 '''
 
+@completer_for('selectStatement', 'selcl')
+def select_statement_consistencylevel(ctxt, cass):
+    return [cl for cl in CqlRuleSet.consistency_levels if cl != 'ANY']
+
 @completer_for('selectWhereClause', 'keyname')
 def select_where_keyname_completer(ctxt, cass):
     cfdef = get_cfdef(ctxt, cass)

Reply via email to