diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py index 28f3ac13ef..d33b5bbfe1 100644 --- a/django/db/backends/mysql/introspection.py +++ b/django/db/backends/mysql/introspection.py @@ -1,3 +1,4 @@ +from django.db.backends.mysql.base import quote_name from MySQLdb.constants import FIELD_TYPE def get_table_list(cursor): @@ -7,7 +8,7 @@ def get_table_list(cursor): def get_table_description(cursor, table_name): "Returns a description of the table, with the DB-API cursor.description interface." - cursor.execute("SELECT * FROM %s LIMIT 1" % table_name) + cursor.execute("SELECT * FROM %s LIMIT 1" % quote_name(table_name)) return cursor.description def get_relations(cursor, table_name): diff --git a/django/db/backends/postgresql/introspection.py b/django/db/backends/postgresql/introspection.py index 778a8e84cb..c06b523211 100644 --- a/django/db/backends/postgresql/introspection.py +++ b/django/db/backends/postgresql/introspection.py @@ -1,3 +1,5 @@ +from django.db.backends.postgresql.base import quote_name + def get_table_list(cursor): "Returns a list of table names in the current database." cursor.execute(""" @@ -11,7 +13,7 @@ def get_table_list(cursor): def get_table_description(cursor, table_name): "Returns a description of the table, with the DB-API cursor.description interface." - cursor.execute("SELECT * FROM %s LIMIT 1" % table_name) + cursor.execute("SELECT * FROM %s LIMIT 1" % quote_name(table_name)) return cursor.description def get_relations(cursor, table_name): diff --git a/django/db/backends/sqlite3/introspection.py b/django/db/backends/sqlite3/introspection.py index 499a4cba84..74c19e22bf 100644 --- a/django/db/backends/sqlite3/introspection.py +++ b/django/db/backends/sqlite3/introspection.py @@ -1,9 +1,11 @@ +from django.db.backends.sqlite3.base import quote_name + def get_table_list(cursor): cursor.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name") return [row[0] for row in cursor.fetchall()] def get_table_description(cursor, table_name): - cursor.execute("PRAGMA table_info(%s)" % table_name) + cursor.execute("PRAGMA table_info(%s)" % quote_name(table_name)) return [(row[1], row[2], None, None) for row in cursor.fetchall()] def get_relations(cursor, table_name):