Ticket #470: 470-2900.diff
File 470-2900.diff, 4.8 KB (added by , 19 years ago) |
---|
-
django/core/management.py
168 168 # We haven't yet created the table to which this field 169 169 # is related, so save it for later. 170 170 pr = pending_references.setdefault(f.rel.to, []).append((klass, f)) 171 table_output.append(' '.join(field_output)) 171 if f.default <> models.fields.NOT_PROVIDED: 172 try: 173 escaped_string = django.db.backend.escapechars(f.default) 174 field_output.append(style.SQL_KEYWORD("DEFAULT '%s'" % (escaped_string,))) 175 except NotImplemented: 176 pass 177 table_output.append(' '.join(field_output)) 172 178 if opts.order_with_respect_to: 173 179 table_output.append(style.SQL_FIELD(backend.quote_name('_order')) + ' ' + \ 174 180 style.SQL_COLTYPE(data_types['IntegerField']) + ' ' + \ -
django/db/backends/ado_mssql/base.py
111 111 if lookup_type=='day': 112 112 return "Convert(datetime, Convert(varchar(12), %s))" % field_name 113 113 114 def escapechars(raw_str): 115 "Escapes problematic characters from SQL in a backend-specific way" 116 working_str = str(raw_str) 117 rawchars = ['"',"'"] 118 cookedchars = ['""',"''"] 119 for i in range(0,len(rawchars)): 120 working_str = working_str.replace(rawchars[i],cookedchars[i]) 121 return working_str 122 114 123 def get_limit_offset_sql(limit, offset=None): 115 124 # TODO: This is a guess. Make sure this is correct. 116 125 sql = "LIMIT %s" % limit -
django/db/backends/dummy/base.py
28 28 dictfetchone = complain 29 29 dictfetchmany = complain 30 30 dictfetchall = complain 31 escapechars = complain 31 32 get_last_insert_id = complain 32 33 get_date_extract_sql = complain 33 34 get_date_trunc_sql = complain -
django/db/backends/mysql/base.py
139 139 sql = "CAST(DATE_FORMAT(%s, '%s') AS DATETIME)" % (field_name, format_str) 140 140 return sql 141 141 142 def escapechars(raw_str): 143 "Escapes problematic characters from SQL in a backend-specific way" 144 working_str = str(raw_str) 145 rawchars = ['\\','"',"'"] 146 cookedchars = ['\\\\','\\"',"\\'"] 147 for i in range(0,len(rawchars)): 148 working_str = working_str.replace(rawchars[i],cookedchars[i]) 149 return working_str 150 142 151 def get_limit_offset_sql(limit, offset=None): 143 152 sql = "LIMIT " 144 153 if offset and offset != 0: -
django/db/backends/postgresql/base.py
89 89 # http://www.postgresql.org/docs/8.0/static/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC 90 90 return "DATE_TRUNC('%s', %s)" % (lookup_type, field_name) 91 91 92 def escapechars(raw_str): 93 "Escapes problematic characters from SQL in a backend-specific way" 94 working_str = str(raw_str) 95 rawchars = ['\\','"',"'"] 96 cookedchars = ['\\\\','\\"',"''"] 97 for i in range(0,len(rawchars)): 98 working_str = working_str.replace(rawchars[i],cookedchars[i]) 99 return working_str 100 92 101 def get_limit_offset_sql(limit, offset=None): 93 102 sql = "LIMIT %s" % limit 94 103 if offset and offset != 0: -
django/db/backends/sqlite3/base.py
123 123 def get_drop_foreignkey_sql(): 124 124 return "" 125 125 126 def escapechars(raw_str): 127 "Escapes problematic characters from SQL in a backend-specific way" 128 # sqlite will happily accept a variety of characters without complaint. Single-quotes, however, must be doubled. 129 working_str = str(raw_str) 130 rawchars = ["'",] 131 cookedchars = ["''",] 132 for i in range(0,len(rawchars)): 133 working_str = working_str.replace(rawchars[i],cookedchars[i]) 134 return working_str 135 126 136 def _sqlite_date_trunc(lookup_type, dt): 127 137 try: 128 138 dt = util.typecast_timestamp(dt) … … 152 162 'istartswith': "LIKE %s ESCAPE '\\'", 153 163 'iendswith': "LIKE %s ESCAPE '\\'", 154 164 } 165