Bug #72391 invalid SQL syntax in query used by inspectdb command
Submitted: 18 Apr 2014 23:46 Modified: 21 Apr 2014 18:39
Reporter: Gary Wilson Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:dev OS:Any
Assigned to: CPU Architecture:Any

[18 Apr 2014 23:46] Gary Wilson
Description:
The following query is executed, but is missing a closing single quote around decimal:

SELECT column_name, numeric_precision, numeric_scale FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = AUM AND table_schema = DATABASE() AND data_type='decimal

How to repeat:
In a django project, run:
python manage.py inspectdb

Suggested fix:
Add missing quote:

diff --git a/python23/django/introspection.py b/python23/django/introspection.py
index d0b8729..699288f 100644
--- a/python23/django/introspection.py
+++ b/python23/django/introspection.py
@@ -62,7 +62,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
         cursor.execute(
             "SELECT column_name, numeric_precision, numeric_scale FROM "
             "INFORMATION_SCHEMA.COLUMNS WHERE table_name = %s AND "
-            "table_schema = DATABASE() AND data_type='decimal", [table_name])
+            "table_schema = DATABASE() AND data_type='decimal'", [table_name])
         numeric_map = dict([(line[0], tuple([int(n) for n in line[1:]]))
             for line in cursor.fetchall()])
[21 Apr 2014 18:39] Sveta Smirnova
Thank you for the report.

This is fixed in current development version. Please wait when it will be uploaded to the downloads web site.