cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1099156 - in /cassandra/branches/cassandra-0.8: CHANGES.txt drivers/py/cql/decoders.py test/system/test_cql.py
Date Tue, 03 May 2011 17:46:10 GMT
Author: jbellis
Date: Tue May  3 17:46:10 2011
New Revision: 1099156

URL: http://svn.apache.org/viewvc?rev=1099156&view=rev
Log:
fix returning null column values in the python cql driver
patch by Pavel Yaskevich; reviewed by jbellis for CASSANDRA-2593

Modified:
    cassandra/branches/cassandra-0.8/CHANGES.txt
    cassandra/branches/cassandra-0.8/drivers/py/cql/decoders.py
    cassandra/branches/cassandra-0.8/test/system/test_cql.py

Modified: cassandra/branches/cassandra-0.8/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/CHANGES.txt?rev=1099156&r1=1099155&r2=1099156&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.8/CHANGES.txt Tue May  3 17:46:10 2011
@@ -1,6 +1,7 @@
 0.8.0-?
  * faster flushes and compaction from fixing excessively pessimistic 
    rebuffering in BRAF (CASSANDRA-2581)
+ * fix returning null column values in the python cql driver (CASSANDRA-2593)
  
 
 0.8.0-beta2

Modified: cassandra/branches/cassandra-0.8/drivers/py/cql/decoders.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/drivers/py/cql/decoders.py?rev=1099156&r1=1099155&r2=1099156&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/drivers/py/cql/decoders.py (original)
+++ cassandra/branches/cassandra-0.8/drivers/py/cql/decoders.py Tue May  3 17:46:10 2011
@@ -59,6 +59,9 @@ class SchemaDecoder(object):
         unmarshal = unmarshallers.get(comparator, unmarshal_noop)
         values = [key]
         for column in row.columns:
+            if column.value == None:
+                continue
+
             description.append((unmarshal(column.name), comparator, None, None, None, None,
True))
             validator = self.__validator_for(keyspace, column_family, column.name)
             values.append(unmarshallers.get(validator, unmarshal_noop)(column.value))

Modified: cassandra/branches/cassandra-0.8/test/system/test_cql.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/test/system/test_cql.py?rev=1099156&r1=1099155&r2=1099156&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/test/system/test_cql.py (original)
+++ cassandra/branches/cassandra-0.8/test/system/test_cql.py Tue May  3 17:46:10 2011
@@ -44,6 +44,10 @@ def load_sample(dbconn):
             WITH comparator = ascii AND default_validation = ascii;
     """)
     dbconn.execute("""
+        CREATE COLUMNFAMILY StandardString2 (KEY text PRIMARY KEY)
+            WITH comparator = ascii AND default_validation = ascii;
+    """)
+    dbconn.execute("""
         CREATE COLUMNFAMILY StandardUtf82 (KEY text PRIMARY KEY)
             WITH comparator = text AND default_validation = ascii;
     """)
@@ -220,6 +224,35 @@ class TestCql(ThriftTester):
         assert r[0] == "aa"
         assert r[1] == "1"
 
+    def test_select_range_with_single_column_results(self):
+        "range should not fail when keys were not set"
+        cursor = init()
+        cursor.execute("""
+          BEGIN BATCH
+            UPDATE StandardString2 SET name='1',password='pass1' WHERE KEY = 'user1'
+            UPDATE StandardString2 SET name='2',password='pass2' WHERE KEY = 'user2'
+            UPDATE StandardString2 SET password='pass3' WHERE KEY = 'user3'
+          APPLY BATCH
+        """)
+
+        cursor.execute("""
+          SELECT name FROM StandardString2
+        """)
+
+        assert cursor.rowcount == 3, "expected 3 results, got %d" % cursor.rowcount
+
+        # two of three results should contain one column "name", third should be empty
+        for i in range(1, 3):
+            r = cursor.fetchone()
+            assert len(r) == 2
+            assert r[0] == "user%d" % i
+            assert r[1] == "%s" % i
+
+        r = cursor.fetchone()
+        assert len(r) == 2
+        assert r[0] == "user3"
+        assert r[1] == None
+
     def test_select_columns_slice_reversed(self):
         "range of columns (slice) by row reversed"
         cursor= init()



Mime
View raw message