diff --git a/CHANGES.txt b/CHANGES.txt index 4ca461d177..855891bdd4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.0-rc2 + * cqlsh: fix DESC TYPE with non-ascii character in the identifier (CASSANDRA-16400) * Remove drivers dependency and bring cql_keywords_reserved on server side (CASSANDRA-16659) * Fix in-browser "help", Python 3 (CASSANDRA-16658) * Fix DROP COMPACT STORAGE for counters (CASSANDRA-16653) diff --git a/bin/cqlsh.py b/bin/cqlsh.py index b879cdcf2f..44086e06f5 100755 --- a/bin/cqlsh.py +++ b/bin/cqlsh.py @@ -618,37 +618,37 @@ class Shell(cmd.Cmd): self.connection_versions = vers def get_keyspace_names(self): - return list(map(str, list(self.conn.metadata.keyspaces.keys()))) + return list(self.conn.metadata.keyspaces) def get_columnfamily_names(self, ksname=None): if ksname is None: ksname = self.current_keyspace - return list(map(str, list(self.get_keyspace_meta(ksname).tables.keys()))) + return list(self.get_keyspace_meta(ksname).tables) def get_materialized_view_names(self, ksname=None): if ksname is None: ksname = self.current_keyspace - return list(map(str, list(self.get_keyspace_meta(ksname).views.keys()))) + return list(self.get_keyspace_meta(ksname).views) def get_index_names(self, ksname=None): if ksname is None: ksname = self.current_keyspace - return list(map(str, list(self.get_keyspace_meta(ksname).indexes.keys()))) + return list(self.get_keyspace_meta(ksname).indexes) def get_column_names(self, ksname, cfname): if ksname is None: ksname = self.current_keyspace layout = self.get_table_meta(ksname, cfname) - return [str(col) for col in layout.columns] + return list(layout.columns) def get_usertype_names(self, ksname=None): if ksname is None: ksname = self.current_keyspace - return list(self.get_keyspace_meta(ksname).user_types.keys()) + return list(self.get_keyspace_meta(ksname).user_types) def get_usertype_layout(self, ksname, typename): if ksname is None: @@ -1400,9 +1400,7 @@ class Shell(cmd.Cmd): """ Print the output for a DESCRIBE KEYSPACES query """ - names = list() - for row in rows: - names.append(str(row['name'])) + names = [ensure_str(r['name']) for r in rows] print('') cmd.Cmd.columnize(self, names) @@ -1422,7 +1420,7 @@ class Shell(cmd.Cmd): keyspace = row['keyspace_name'] names = list() - names.append(str(row['name'])) + names.append(ensure_str(row['name'])) if keyspace is not None: self.print_keyspace_element_names(keyspace, names) diff --git a/pylib/cqlshlib/copyutil.py b/pylib/cqlshlib/copyutil.py index 1056c52a4e..d22bf8ba2d 100644 --- a/pylib/cqlshlib/copyutil.py +++ b/pylib/cqlshlib/copyutil.py @@ -560,7 +560,7 @@ class ExportWriter(object): if self.header: writer = csv.writer(self.current_dest.output, **self.options.dialect) - writer.writerow(self.columns) + writer.writerow([ensure_str(c) for c in self.columns]) return True diff --git a/pylib/cqlshlib/test/test_cqlsh_completion.py b/pylib/cqlshlib/test/test_cqlsh_completion.py index 8b296b8f9b..c898cbed04 100644 --- a/pylib/cqlshlib/test/test_cqlsh_completion.py +++ b/pylib/cqlshlib/test/test_cqlsh_completion.py @@ -696,10 +696,7 @@ class TestCqlshCompletion(CqlshCompletionCase): self.trycompletions('CREATE TA', immediate='BLE ') self.create_columnfamily_table_template('TABLE') - def test_complete_in_describe(self): - """ - Tests for Cassandra-10733 - """ + def test_complete_in_describe(self): # Cassandra-10733 self.trycompletions('DES', immediate='C') # quoted_keyspace = '"' + self.cqlsh.keyspace + '"' self.trycompletions('DESCR', immediate='IBE ') diff --git a/pylib/cqlshlib/test/test_unicode.py b/pylib/cqlshlib/test/test_unicode.py index b31e81c991..836c2d9b8b 100644 --- a/pylib/cqlshlib/test/test_unicode.py +++ b/pylib/cqlshlib/test/test_unicode.py @@ -56,10 +56,20 @@ class TestCqlshUnicode(BaseTestCase): output = c.cmd_and_response('SELECT * FROM t;') self.assertIn(col_name, output) - def test_multiline_input(self): # CASSANDRA-16539 + def test_unicode_multiline_input(self): # CASSANDRA-16400 with testrun_cqlsh(tty=True, env=self.default_env) as c: value = '値' c.send("INSERT INTO t(k, v) VALUES (1, \n'%s');\n" % (value,)) c.read_to_next_prompt() output = c.cmd_and_response('SELECT v FROM t;') self.assertIn(value, output) + + def test_unicode_desc(self): # CASSANDRA-16539 + with testrun_cqlsh(tty=True, env=self.default_env) as c: + v1 = 'ࠑ' + v2 = 'Ξ' + output = c.cmd_and_response('CREATE TYPE "%s" ( "%s" int );' % (v1, v2)) + output = c.cmd_and_response('DESC TYPES;') + self.assertIn(v1, output) + output = c.cmd_and_response('DESC TYPE "%s";' %(v1,)) + self.assertIn(v2, output)