diff --git a/CHANGES.txt b/CHANGES.txt index 2d14e34ee1..eb0b66e299 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,6 +3,8 @@ * Run evictFromMembership in GossipStage (CASSANDRA-15592) Merged from 2.2: * Disable JMX rebinding (CASSANDRA-15653) +Merged from 2.1: + * Fix parse error in cqlsh COPY FROM and formatting for map of blobs (CASSANDRA-15679) * Fix Commit log replays when static column clustering keys are collections (CASSANDRA-14365) * Fix Red Hat init script on newer systemd versions (CASSANDRA-15273) * Allow EXTRA_CLASSPATH to work on tar/source installations (CASSANDRA-15567) diff --git a/pylib/cqlshlib/copyutil.py b/pylib/cqlshlib/copyutil.py index da1fef9b81..6a45153601 100644 --- a/pylib/cqlshlib/copyutil.py +++ b/pylib/cqlshlib/copyutil.py @@ -53,7 +53,7 @@ from cassandra.util import Date, Time from cql3handling import CqlRuleSet from displaying import NO_COLOR_MAP -from formatting import format_value_default, DateTimeFormat, EMPTY, get_formatter +from formatting import format_value_default, DateTimeFormat, EMPTY, get_formatter, BlobType from sslhandling import ssl_settings PROFILE_ON = False @@ -1846,7 +1846,7 @@ class ImportConversion(object): return converters.get(t.typename, convert_unknown)(v, ct=t) def convert_blob(v, **_): - return bytearray.fromhex(v[2:]) + return BlobType(v[2:].decode("hex")) def convert_text(v, **_): return v diff --git a/pylib/cqlshlib/formatting.py b/pylib/cqlshlib/formatting.py index dfef60963d..53ba478a13 100644 --- a/pylib/cqlshlib/formatting.py +++ b/pylib/cqlshlib/formatting.py @@ -147,13 +147,20 @@ def formatter_for(typname): return f return registrator +class BlobType(object): + def __init__(self, val): + self.val = val -@formatter_for('bytearray') + def __str__(self): + return str(self.val) + +@formatter_for('BlobType') def format_value_blob(val, colormap, **_): bval = '0x' + binascii.hexlify(val) return colorme(bval, colormap, 'blob') +formatter_for('bytearray')(format_value_blob) formatter_for('buffer')(format_value_blob)