From 3f883bf4d514cf8175d5d7bcbb6af16908905bdb Mon Sep 17 00:00:00 2001 From: Aleksey Yeschenko Date: Tue, 2 Apr 2013 22:08:59 +0300 Subject: [PATCH] cqlsh: Print maps ordered by key, sort sets patch by Aleksey Yeschenko; reviewed by Brandon Williams for CASSANDRA-5413 --- CHANGES.txt | 1 + pylib/cqlshlib/formatting.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7e906ce7ca..58ba39aaf7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -18,6 +18,7 @@ * Fix writetime/ttl functions on null values (CASSANDRA-5341) * Fix NPE during cql3 select with token() (CASSANDRA-5404) * IndexHelper.skipBloomFilters won't skip non-SHA filters (CASSANDRA-5385) + * cqlsh: Print maps ordered by key, sort sets (CASSANDRA-5413) Merged from 1.1: * cli: Quote ks and cf names in schema output when needed (CASSANDRA-5052) * Fix bad default for min/max timestamp in SSTableMetadata (CASSANDRA-5372) diff --git a/pylib/cqlshlib/formatting.py b/pylib/cqlshlib/formatting.py index b970eb9e00..a3d4666370 100644 --- a/pylib/cqlshlib/formatting.py +++ b/pylib/cqlshlib/formatting.py @@ -202,7 +202,7 @@ def format_value_list(val, encoding, colormap, time_format, float_precision, sub @formatter_for('set') def format_value_set(val, encoding, colormap, time_format, float_precision, subtypes, nullval, **_): - return format_simple_collection(subtypes[0], val, '{', '}', encoding, colormap, + return format_simple_collection(subtypes[0], sorted(val), '{', '}', encoding, colormap, time_format, float_precision, nullval) @formatter_for('map') @@ -213,7 +213,7 @@ def format_value_map(val, encoding, colormap, time_format, float_precision, subt nullval=nullval) subkeytype, subvaltype = subtypes - subs = [(subformat(k, subkeytype), subformat(v, subvaltype)) for (k, v) in val.items()] + subs = [(subformat(k, subkeytype), subformat(v, subvaltype)) for (k, v) in sorted(val.items())] bval = '{' + ', '.join(k.strval + ': ' + v.strval for (k, v) in subs) + '}' lb, comma, colon, rb = [colormap['collection'] + s + colormap['reset'] for s in ('{', ', ', ': ', '}')]