diff --git a/CHANGES.txt b/CHANGES.txt index 9342825817..ce4775b989 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,8 @@ Merged from 3.0: * 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 7f97b49ecf..b91bb766ac 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, CqlType, DateTimeFormat, EMPTY, get_formatter +from formatting import format_value_default, CqlType, DateTimeFormat, EMPTY, get_formatter, BlobType from sslhandling import ssl_settings PROFILE_ON = False @@ -1868,7 +1868,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 803ea63f89..9927aa187e 100644 --- a/pylib/cqlshlib/formatting.py +++ b/pylib/cqlshlib/formatting.py @@ -236,13 +236,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) formatter_for('blob')(format_value_blob)