Django

Code

Changeset 1581

Show
Ignore:
Timestamp:
12/08/05 21:08:51 (3 years ago)
Author:
adrian
Message:

Fixed #967 -- 'tables' parameter in DB API is now only quoted if needed. Thanks, Russell Keith-Magee

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/AUTHORS

    r1579 r1581  
    5757    Jason Huggins <http://www.jrandolph.com/blog/> 
    5858    Michael Josephson <http://www.sdjournal.com/> 
     59    Russell Keith-Magee <freakboy@iinet.net.au> 
    5960    Garth Kidd <http://www.deadlybloodyserious.com/> 
    6061    Sune Kirkeby <http://ibofobi.dk/> 
  • django/trunk/django/core/meta/__init__.py

    r1550 r1581  
    15851585 
    15861586def 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. 
    15871594    select = ["%s.%s" % (db.db.quote_name(opts.db_table), db.db.quote_name(f.column)) for f in opts.fields] 
    15881595    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] 
    15901597    where = kwargs.get('where') and kwargs['where'][:] or [] 
    15911598    params = kwargs.get('params') and kwargs['params'][:] or [] 
     
    16051612 
    16061613    # 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) 
    16121614    if kwargs.get('select'): 
    16131615        select.extend(['(%s) AS %s' % (quote_only_if_word(s[1]), db.db.quote_name(s[0])) for s in kwargs['select']])