#18782: database "view" treated as "table" on flush (mysql) -------------------------------------+------------------------------------- Reporter: rodolfo_3 | Owner: nobody Type: Uncategorized | Status: new Component: Database layer | Version: 1.4 (models, ORM) | Keywords: mysql introspection Severity: Normal | table view Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- I'm using a mysql view (https://dev.mysql.com/doc/refman/5.0/en/create- view.html) on a Mysql database to replace a default "auth_user_group" table on a django project. I replace the table in a "post_syncdb" signal.
When I run the tests, django try to "flush" the database, executing a "truncate", it try do it with the view too. It's cause a database error, and fail the flush: {{{ Error: Database test_yoshi couldn't be flushed. Possible reasons: * The database isn't running or isn't configured correctly. * At least one of the expected database tables doesn't exist. * The SQL was invalid. Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run. The full error: (1146, "Table 'test_yoshi.auth_user_groups' doesn't exist") }}} It's happen because the command to inspect the database on mysql backend use the command "show tables". But, on mysql, views are returned by this command: https://dev.mysql.com/doc/refman/5.0/en/show-tables.html The solution is replace the query on the method "get_table_list" on the file "db/backends/mysql/introspection.py": {{{ def get_table_list(self, cursor): "Returns a list of table names in the current database." cursor.execute("SHOW FULL TABLES WHERE TABLE_TYPE = 'BASE TABLE'") return [row[0] for row in cursor.fetchall()] }}} -- Ticket URL: <https://code.djangoproject.com/ticket/18782> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.