You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jm...@apache.org on 2015/12/23 19:24:49 UTC
[03/10] cassandra git commit: Fix multiple consecutive delimiters on
cqlsh COPY FROM
Fix multiple consecutive delimiters on cqlsh COPY FROM
Patch by stefania; reviewed by pmotta for CASSANDRA-10854
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/3ccffc94
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/3ccffc94
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/3ccffc94
Branch: refs/heads/cassandra-3.0
Commit: 3ccffc94b8a6127f6a452a3fb93306ad3bbc8c97
Parents: 7c3966b
Author: Stefania Alborghetti <st...@datastax.com>
Authored: Tue Dec 22 09:16:54 2015 +0100
Committer: Joshua McKenzie <jm...@apache.org>
Committed: Wed Dec 23 13:20:27 2015 -0500
----------------------------------------------------------------------
pylib/cqlshlib/copyutil.py | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/3ccffc94/pylib/cqlshlib/copyutil.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/copyutil.py b/pylib/cqlshlib/copyutil.py
index f699e64..65f5997 100644
--- a/pylib/cqlshlib/copyutil.py
+++ b/pylib/cqlshlib/copyutil.py
@@ -1020,16 +1020,19 @@ class ImportConversion(object):
ret[i] = self.converters[self.columns[i]](val)
else:
if i in self.primary_key_indexes:
- message = "Cannot insert null value for primary key column '%s'." % (self.columns[i],)
- if self.nullval == '':
- message += " If you want to insert empty strings, consider using" \
- " the WITH NULL=<marker> option for COPY."
- raise Exception(message=message)
+ raise ValueError(self.get_null_primary_key_message(i))
ret[i] = None
return ret
+ def get_null_primary_key_message(self, idx):
+ message = "Cannot insert null value for primary key column '%s'." % (self.columns[idx],)
+ if self.nullval == '':
+ message += " If you want to insert empty strings, consider using" \
+ " the WITH NULL=<marker> option for COPY."
+ return message
+
def get_row_partition_key_values(self, row):
"""
Return a string composed of the partition key values, serialized and binary packed -
@@ -1037,6 +1040,8 @@ class ImportConversion(object):
"""
def serialize(n):
c, v = self.columns[n], row[n]
+ if v == self.nullval:
+ raise ValueError(self.get_null_primary_key_message(n))
return self.cqltypes[c].serialize(self.converters[c](v), self.proto_version)
partition_key_indexes = self.partition_key_indexes