Author: eevans
Date: Wed Mar 23 23:23:28 2011
New Revision: 1084803

URL: http://svn.apache.org/viewvc?rev=1084803&view=rev
Log:
negative numerical terms (+ tests)

Patch by eevans

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g
    cassandra/trunk/test/system/test_cql.py

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g?rev=1084803&r1=1084802&r2=1084803&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/Cql.g Wed Mar 23 23:23:28 
2011
@@ -412,7 +412,7 @@ RANGEOP
     ;
 
 INTEGER
-    : DIGIT+
+    : '-'? DIGIT+
     ;
 
 /* Normally a lexer only emits one token at a time, but ours is tricked out

Modified: cassandra/trunk/test/system/test_cql.py
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_cql.py?rev=1084803&r1=1084802&r2=1084803&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_cql.py (original)
+++ cassandra/trunk/test/system/test_cql.py Wed Mar 23 23:23:28 2011
@@ -553,6 +553,21 @@ class TestCql(ThriftTester):
         assert r[0][1].name == u"®"
         assert r[0][2].name == u"¿"
         
-        
-
+    def test_read_write_negative_numerics(self):
+        "reading and writing negative numeric values"
+        conn = init()
+        for cf in ("StandardIntegerA", "StandardLongA"):
+            for i in range(10):
+                conn.execute("UPDATE ? SET ? = ? WHERE KEY = negatives;",
+                             cf,
+                             -(i + 1),
+                             i)
+            r = conn.execute("SELECT ?..? FROM ? WHERE KEY = negatives;",
+                             -10,
+                             -1,
+                             cf)
+            assert len(r[0]) == 10, \
+                "returned %d columns, expected %d" % (len(r[0]), 10)
+            assert r[0][0].name == -10
+            assert r[0][9].name == -1
         


Reply via email to