]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Modified MySQLDialect.get_view_names() to also return system views such as those...
authorelazar <tobias382@gmail.com>
Thu, 12 Apr 2012 02:32:00 +0000 (21:32 -0500)
committerelazar <tobias382@gmail.com>
Thu, 12 Apr 2012 02:32:00 +0000 (21:32 -0500)
lib/sqlalchemy/dialects/mysql/base.py
test/dialect/test_mysql.py

index 65c2c59b9f6c562cfd829f00707d5ee2dba125f5..7d856f0b7da77516277cafafc04631470cf7015b 100644 (file)
@@ -2021,7 +2021,6 @@ class MySQLDialect(default.DefaultDialect):
 
     @reflection.cache
     def get_view_names(self, connection, schema=None, **kw):
-        charset = self._connection_charset
         if self.server_version_info < (5, 0, 2):
             raise NotImplementedError
         if schema is None:
@@ -2032,7 +2031,7 @@ class MySQLDialect(default.DefaultDialect):
         rp = connection.execute("SHOW FULL TABLES FROM %s" %
                 self.identifier_preparer.quote_identifier(schema))
         return [row[0] for row in self._compat_fetchall(rp, charset=charset)\
-                                                    if row[1] == 'VIEW']
+                                                    if 'VIEW' in row[1]]
 
     @reflection.cache
     def get_table_options(self, connection, table_name, schema=None, **kw):
index 9a2e17ecc1925c931ae5e419b90cc86226d26736..a5623a3bdea9625521ce8a6b4f95cd0f667ccdda 100644 (file)
@@ -108,6 +108,14 @@ class DialectTest(fixtures.TestBase):
             }
         )
 
+    @testing.only_on(['mysql'],
+                    'requires information_schema')
+    def test_system_views(self):
+        dialect = testing.db.dialect
+        connection = testing.db.connect()
+        view_names = dialect.get_view_names(connection, "information_schema")
+        self.assert_('TABLES' in view_names)
+
 class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
     "Test MySQL column types"