From aec8f16705a4fea6c33e84d5a40d370b99c518e4 Mon Sep 17 00:00:00 2001 From: Aleksey Yeschenko Date: Sun, 24 Nov 2013 21:51:26 +0300 Subject: [PATCH] cqlsh: quote single quotes in strings inside collections patch by Mikhail Stepura; reviewed by Aleksey Yeschenko for CASSANDRA-6172 --- CHANGES.txt | 1 + pylib/cqlshlib/formatting.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index c012148143..57c1896f23 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,7 @@ * Optimize FD phi calculation (CASSANDRA-6386) * Improve initial FD phi estimate when starting up (CASSANDRA-6385) * Don't list CQL3 table in CLI describe even if named explicitely (CASSANDRA-5750) + * cqlsh: quote single quotes in strings inside collections (CASSANDRA-6172) 1.2.12 diff --git a/pylib/cqlshlib/formatting.py b/pylib/cqlshlib/formatting.py index b571033765..44392ceef2 100644 --- a/pylib/cqlshlib/formatting.py +++ b/pylib/cqlshlib/formatting.py @@ -180,6 +180,8 @@ def strftime(time_format, seconds): @formatter_for('text') def format_value_text(val, encoding, colormap, quote=False, **_): escapedval = val.replace(u'\\', u'\\\\') + if quote: + escapedval = escapedval.replace("'", "''") escapedval = unicode_controlchars_re.sub(_show_control_chars, escapedval) bval = escapedval.encode(encoding, 'backslashreplace') if quote: