mirror of https://github.com/apache/cassandra
Fix multiple consecutive delimiters on cqlsh COPY FROM
Patch by stefania; reviewed by pmotta for CASSANDRA-10854
This commit is contained in:
parent
7c3966bfe3
commit
3ccffc94b8
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue