cqlsh: Print maps ordered by key, sort sets

patch by Aleksey Yeschenko; reviewed by Brandon Williams for
CASSANDRA-5413
This commit is contained in:
Aleksey Yeschenko 2013-04-02 22:08:59 +03:00
parent 4f75875c2e
commit 3f883bf4d5
2 changed files with 3 additions and 2 deletions

View File

@ -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)

View File

@ -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 ('{', ', ', ': ', '}')]