Ticket #18218: 18218-1.diff

File 18218-1.diff, 2.1 KB (added by Claude Paroz, 13 years ago)

Sort table names in get_table_list

  • django/db/backends/oracle/introspection.py

    diff --git a/django/db/backends/oracle/introspection.py b/django/db/backends/oracle/introspection.py
    index b8a8b2e..f426834 100644
    a b class DatabaseIntrospection(BaseDatabaseIntrospection):  
    3939
    4040    def get_table_list(self, cursor):
    4141        "Returns a list of table names in the current database."
    42         cursor.execute("SELECT TABLE_NAME FROM USER_TABLES")
     42        cursor.execute("SELECT TABLE_NAME FROM USER_TABLES ORDER BY TABLE_NAME")
    4343        return [row[0].lower() for row in cursor.fetchall()]
    4444
    4545    def get_table_description(self, cursor, table_name):
  • django/db/backends/postgresql_psycopg2/introspection.py

    diff --git a/django/db/backends/postgresql_psycopg2/introspection.py b/django/db/backends/postgresql_psycopg2/introspection.py
    index 2fa1248..f02424e 100644
    a b class DatabaseIntrospection(BaseDatabaseIntrospection):  
    3030            LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
    3131            WHERE c.relkind IN ('r', 'v', '')
    3232                AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
    33                 AND pg_catalog.pg_table_is_visible(c.oid)""")
     33                AND pg_catalog.pg_table_is_visible(c.oid)
     34            ORDER BY c.relname""")
    3435        return [row[0] for row in cursor.fetchall()]
    3536
    3637    def get_table_description(self, cursor, table_name):
  • tests/regressiontests/introspection/tests.py

    diff --git a/tests/regressiontests/introspection/tests.py b/tests/regressiontests/introspection/tests.py
    index 3bd9d60..b425b64 100644
    a b class IntrospectionTests(TestCase):  
    4040
    4141    def test_table_names(self):
    4242        tl = connection.introspection.table_names()
     43        self.assertEqual(tl, sorted(tl))
    4344        self.assertTrue(Reporter._meta.db_table in tl,
    4445                     "'%s' isn't in table_list()." % Reporter._meta.db_table)
    4546        self.assertTrue(Article._meta.db_table in tl,
Back to Top