From 65bd45523584302572782c45b352bbd2bbd3c558 Mon Sep 17 00:00:00 2001 From: Stefania Alborghetti Date: Fri, 23 Dec 2016 15:12:14 +0800 Subject: [PATCH] Replace empty strings with null values if they cannot be converted patch by Stefania Alborghetti; reviewed by Tyler Hobbs for CASSANDRA-12794 --- CHANGES.txt | 1 + pylib/cqlshlib/copyutil.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 77a310dc2e..11b0482e55 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.0.11 + * Replace empty strings with null values if they cannot be converted (CASSANDRA-12794) * Fixed flacky SSTableRewriterTest: check file counts before calling validateCFS (CASSANDRA-12348) * Fix deserialization of 2.x DeletedCells (CASSANDRA-12620) * Add parent repair session id to anticompaction log message (CASSANDRA-12186) diff --git a/pylib/cqlshlib/copyutil.py b/pylib/cqlshlib/copyutil.py index b474f3e9ef..facf9ddd2a 100644 --- a/pylib/cqlshlib/copyutil.py +++ b/pylib/cqlshlib/copyutil.py @@ -2054,6 +2054,13 @@ class ImportConversion(object): try: return c(v) if v != self.nullval else self.get_null_val() except Exception, e: + # if we could not convert an empty string, then self.nullval has been set to a marker + # because the user needs to import empty strings, except that the converters for some types + # will fail to convert an empty string, in this case the null value should be inserted + # see CASSANDRA-12794 + if v == '': + return self.get_null_val() + if self.debug: traceback.print_exc() raise ParseError("Failed to parse %s : %s" % (val, e.message))