Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #967 -- 'tables' parameter in DB API is now only quoted if need…

…ed. Thanks, Russell Keith-Magee

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1581 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5fe45cb0f851ea083c1e25664ded93432a62ab05 1 parent a8b3d67
Adrian Holovaty authored
1  AUTHORS
@@ -56,6 +56,7 @@ answer newbie questions, and generally made Django that much better:
56 56
     Robert Rock Howard <http://djangomojo.com/>
57 57
     Jason Huggins <http://www.jrandolph.com/blog/>
58 58
     Michael Josephson <http://www.sdjournal.com/>
  59
+    Russell Keith-Magee <freakboy@iinet.net.au>
59 60
     Garth Kidd <http://www.deadlybloodyserious.com/>
60 61
     Sune Kirkeby <http://ibofobi.dk/>
61 62
     lakin.wecker@gmail.com
14  django/core/meta/__init__.py
@@ -1584,9 +1584,16 @@ def _parse_lookup(kwarg_items, opts, table_count=0):
1584 1584
     return tables, join_where, where, params, table_count
1585 1585
 
1586 1586
 def function_get_sql_clause(opts, **kwargs):
  1587
+    def quote_only_if_word(word):
  1588
+        if ' ' in word:
  1589
+            return word
  1590
+        else:
  1591
+            return db.db.quote_name(word)
  1592
+
  1593
+    # Construct the fundamental parts of the query: SELECT X FROM Y WHERE Z.
1587 1594
     select = ["%s.%s" % (db.db.quote_name(opts.db_table), db.db.quote_name(f.column)) for f in opts.fields]
1588 1595
     tables = [opts.db_table] + (kwargs.get('tables') and kwargs['tables'][:] or [])
1589  
-    tables = [db.db.quote_name(t) for t in tables]
  1596
+    tables = [quote_only_if_word(t) for t in tables]
1590 1597
     where = kwargs.get('where') and kwargs['where'][:] or []
1591 1598
     params = kwargs.get('params') and kwargs['params'][:] or []
1592 1599
 
@@ -1604,11 +1611,6 @@ def function_get_sql_clause(opts, **kwargs):
1604 1611
         _fill_table_cache(opts, select, tables, where, opts.db_table, [opts.db_table])
1605 1612
 
1606 1613
     # Add any additional SELECTs passed in via kwargs.
1607  
-    def quote_only_if_word(word):
1608  
-        if word.find(' ')>=0:
1609  
-            return word
1610  
-        else:
1611  
-            return db.db.quote_name(word)
1612 1614
     if kwargs.get('select'):
1613 1615
         select.extend(['(%s) AS %s' % (quote_only_if_word(s[1]), db.db.quote_name(s[0])) for s in kwargs['select']])
1614 1616
 

0 notes on commit 5fe45cb

Please sign in to comment.
Something went wrong with that request. Please try again.