Skip to content

Commit

Permalink
Merge f93f9f1 into f4d33e7
Browse files Browse the repository at this point in the history
  • Loading branch information
chaudum committed Oct 22, 2019
2 parents f4d33e7 + f93f9f1 commit f308ec7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -5,6 +5,8 @@ Changes for crash
Unreleased
==========

- Sort the output of the ``\dt`` (show tables) command alphabetically.

- Improved the color scheme for the SQL syntax hightlighing.

- Dropped support for Python 3.4 and added official support for Python 3.7
Expand Down
3 changes: 2 additions & 1 deletion crate/crash/command.py
Expand Up @@ -319,7 +319,8 @@ def _show_tables(self, *args):
"SELECT format('%s.%s', {schema}, table_name) AS name "
"FROM information_schema.tables "
"WHERE {schema} NOT IN ('sys','information_schema', 'pg_catalog')"
"{table_filter}".format(schema=schema_name, table_filter=table_filter))
"{table_filter} "
"ORDER BY 1".format(schema=schema_name, table_filter=table_filter))

@noargs_command
def _quit(self, *args):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_commands.py
Expand Up @@ -133,21 +133,21 @@ def test_post_2_0(self):
cmd._exec_and_print = MagicMock()
cmd.connection.lowest_server_version = StrictVersion("2.0.0")
cmd._show_tables()
cmd._exec_and_print.assert_called_with("SELECT format('%s.%s', table_schema, table_name) AS name FROM information_schema.tables WHERE table_schema NOT IN ('sys','information_schema', 'pg_catalog') AND table_type = 'BASE TABLE'")
cmd._exec_and_print.assert_called_with("SELECT format('%s.%s', table_schema, table_name) AS name FROM information_schema.tables WHERE table_schema NOT IN ('sys','information_schema', 'pg_catalog') AND table_type = 'BASE TABLE' ORDER BY 1")

def test_post_0_57(self):
cmd = CrateShell()
cmd._exec_and_print = MagicMock()
cmd.connection.lowest_server_version = StrictVersion("0.57.0")
cmd._show_tables()
cmd._exec_and_print.assert_called_with("SELECT format('%s.%s', table_schema, table_name) AS name FROM information_schema.tables WHERE table_schema NOT IN ('sys','information_schema', 'pg_catalog')")
cmd._exec_and_print.assert_called_with("SELECT format('%s.%s', table_schema, table_name) AS name FROM information_schema.tables WHERE table_schema NOT IN ('sys','information_schema', 'pg_catalog') ORDER BY 1")

def test_pre_0_57(self):
cmd = CrateShell()
cmd._exec_and_print = MagicMock()
cmd.connection.lowest_server_version = StrictVersion("0.56.4")
cmd._show_tables()
cmd._exec_and_print.assert_called_with("SELECT format('%s.%s', schema_name, table_name) AS name FROM information_schema.tables WHERE schema_name NOT IN ('sys','information_schema', 'pg_catalog')")
cmd._exec_and_print.assert_called_with("SELECT format('%s.%s', schema_name, table_name) AS name FROM information_schema.tables WHERE schema_name NOT IN ('sys','information_schema', 'pg_catalog') ORDER BY 1")


class ChecksCommandTest(TestCase):
Expand Down

0 comments on commit f308ec7

Please sign in to comment.