cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [1/2] git commit: cqlsh: fix COPY FROM handling of null/empty PK values
Date Tue, 19 Aug 2014 19:55:20 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 92325cc12 -> 3a03d4bd5


cqlsh: fix COPY FROM handling of null/empty PK values

Patch by Tyler Hobbs; reviewed by Aleksey Yeschenko for CASSANDRA-7792


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

Branch: refs/heads/cassandra-2.1
Commit: 94262c43908904303610c1243531a00167c03e0f
Parents: 853e772
Author: Tyler Hobbs <tyler@datastax.com>
Authored: Tue Aug 19 14:53:57 2014 -0500
Committer: Tyler Hobbs <tyler@datastax.com>
Committed: Tue Aug 19 14:53:57 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt |  2 ++
 bin/cqlsh   | 12 +++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/94262c43/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index ca58708..5113057 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.1.0
+ * (cqlsh) Fix COPY FROM handling of null/empty primary key
+   values (CASSANDRA-7792)
  * Fix ordering of static cells (CASSANDRA-7763)
 Merged from 2.0:
  * Fix PRSI handling of CQL3 row markers for row cleanup (CASSANDRA-7787)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/94262c43/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index ab1e215..4c90f2d 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -1344,7 +1344,7 @@ class Shell(cmd.Cmd):
 
     def do_import_row(self, columns, nullval, table_meta, row):
         rowmap = {}
-        clustering_key_columns = [col.name for col in table_meta.clustering_key]
+        primary_key_columns = [col.name for col in table_meta.primary_key]
         for name, value in zip(columns, row):
             type = table_meta.columns[name].data_type
             cqltype = table_meta.columns[name].typestring
@@ -1354,8 +1354,14 @@ class Shell(cmd.Cmd):
                     rowmap[name] = protect_value(value)
                 else:
                     rowmap[name] = value
-            elif name in clustering_key_columns and not type.empty_binary_ok:
-                rowmap[name] = 'blobAs%s(0x)' % cqltype.title()
+            elif name in primary_key_columns:
+                # By default, nullval is an empty string. See CASSANDRA-7792 for details.
+                message = "Cannot insert null value for primary key column '%s'." % (name,)
+                if nullval == '':
+                    message += " If you want to insert empty strings, consider using " \
+                               "the WITH NULL=<marker> option for COPY."
+                self.printerr(message)
+                return False
             else:
                 rowmap[name] = 'null'
         return self.do_import_insert(table_meta, rowmap)


Mime
View raw message