Ticket #121: fixed_quote_name.patch

File fixed_quote_name.patch, 2.4 KB (added by rmunn@…, 19 years ago)

Fixed patch to add quote_name() to all db backends - previous patch had wrong linecounts

  • django/core/db/__init__.py

     
    3737get_last_insert_id = dbmod.get_last_insert_id
    3838get_date_extract_sql = dbmod.get_date_extract_sql
    3939get_date_trunc_sql = dbmod.get_date_trunc_sql
     40quote_name = dbmod.quote_name
    4041OPERATOR_MAPPING = dbmod.OPERATOR_MAPPING
    4142DATA_TYPES = dbmod.DATA_TYPES
  • django/core/db/backends/postgresql.py

     
    7171    # http://www.postgresql.org/docs/8.0/static/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC
    7272    return "DATE_TRUNC('%s', %s)" % (lookup_type, field_name)
    7373
     74def quote_name(name):
     75    if name.startswith('"') and name.endswith('"'):
     76        # Quoting once is enough!
     77        return name
     78    else:
     79        return '"%s"' % name
     80
    7481# Register these custom typecasts, because Django expects dates/times to be
    7582# in Python's native (standard-library) datetime/time format, whereas psycopg
    7683# use mx.DateTime by default.
  • django/core/db/backends/sqlite3.py

     
    9898    elif lookup_type == 'day':
    9999        return "%i-%02i-%02i 00:00:00" % (dt.year, dt.month, dt.day)
    100100
     101def quote_name(name):
     102    if name.startswith('"') and name.endswith('"'):
     103        # Quoting once is enough!
     104        return name
     105    else:
     106        return '"%s"' % name
     107
    101108# Operators and fields ########################################################
    102109       
    103110OPERATOR_MAPPING = {
  • django/core/db/backends/mysql.py

     
    6868        subtractions.append(" - interval (DATE_FORMAT(%s, '%%%%m')-1) month" % field_name)
    6969    return "(%s - %s)" % (field_name, ''.join(subtractions))
    7070
     71def quote_name(name):
     72    if name.startswith("`") and name.endswith("`"):
     73        # Quoting once is enough!
     74        return name
     75    else:
     76        return "`%s`" % name
     77
    7178OPERATOR_MAPPING = {
    7279    'exact': '=',
    7380    'iexact': 'LIKE',
Back to Top