Ticket #18782: fix18782.diff

File fix18782.diff, 1.5 KB (added by rodolfo_3, 12 years ago)

diff with a solution and a regression test

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

    diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py
    index 041fbee..ac93d68 100644
    a b class DatabaseIntrospection(BaseDatabaseIntrospection):  
    3232
    3333    def get_table_list(self, cursor):
    3434        "Returns a list of table names in the current database."
    35         cursor.execute("SHOW TABLES")
     35        cursor.execute("SHOW FULL TABLES WHERE TABLE_TYPE = 'BASE TABLE'")
    3636        return [row[0] for row in cursor.fetchall()]
    3737
    3838    def get_table_description(self, cursor, table_name):
  • tests/regressiontests/backends/tests.py

    diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py
    index dc92189..a695430 100644
    a b class MySQLTests(TestCase):  
    110110        connection.mysql_version
    111111        self.assertTrue(connection.connection is None)
    112112
     113    @unittest.skipUnless(connection.vendor == 'mysql',
     114                        "Test valid only for MySQL")
     115    def test_inspect_tables_view(self):
     116        """
     117        Check if a view is not returned as a table
     118        Refs #18782
     119        """
     120        cursor = connection.cursor()
     121        cursor.execute('create view my_view as select 1 f')
     122        tables = connection.introspection.get_table_list(cursor)
     123        self.assertFalse('my_view' in tables)
     124        cursor.close()
     125
    113126class DateQuotingTest(TestCase):
    114127
    115128    def test_django_date_trunc(self):
Back to Top