Matthew Turland avatar Matthew Turland committed 60b2077

Modified MySQLDialect.get_view_names() to also return system views such as those in information_schema

Comments (0)

Files changed (2)


     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:
         rp = connection.execute("SHOW FULL TABLES FROM %s" %
         return [row[0] for row in self._compat_fetchall(rp, charset=charset)\
-                                                    if row[1] == 'VIEW']
+                                                    if 'VIEW' in row[1]]
     def get_table_options(self, connection, table_name, schema=None, **kw):


+    @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"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.