Ticket #470: 470-2.patch
File 470-2.patch, 2.7 KB (added by , 19 years ago) |
---|
-
django/core/db/backends/postgresql.py
53 53 if name.startswith('"') and name.endswith('"'): 54 54 return name # Quoting once is enough. 55 55 return '"%s"' % name 56 57 def escapechars(self,rawstring): 58 "Escapes dangerous characters from SQL in a backend-specific way" 59 # important to process backslashes first, otherwise characters are substituted twice! 60 cookedstring = rawstring.replace('\\','\\\\') 61 cookedstring = rawstring.replace("'","''") 62 cookedstring = rawstring.replace('"','\"') 63 cookedstring = rawstring.replace('*','\*') 64 cookedstring = rawstring.replace('_','\_') 65 cookedstring = rawstring.replace(';','\;') 66 return cookedstring 56 67 57 68 def dictfetchone(cursor): 58 69 "Returns a row from the cursor as a dict" -
django/core/db/backends/sqlite3.py
55 55 self.connection.close() 56 56 self.connection = None 57 57 58 def escapechars(self,rawstring): 59 "Escapes dangerous characters from SQL in a backend-specific way" 60 # sqlite will happily accept a variety of characters without complaint. Single-quotes, however, must be doubled. 61 cookedstring = rawstring.replace("'","''") 62 return cookedstring 63 58 64 def quote_name(self, name): 59 65 if name.startswith('"') and name.endswith('"'): 60 66 return name # Quoting once is enough. -
django/core/management.py
81 81 field_output.append('REFERENCES %s (%s)' % \ 82 82 (db.db.quote_name(f.rel.to.db_table), 83 83 db.db.quote_name(f.rel.to.get_field(f.rel.field_name).column))) 84 if f.default <> meta.fields.NOT_PROVIDED: 85 try: 86 escaped_string = db.db.escapechars("DEFAULT '%s'" % (f.default,)) 87 field_output.append(escaped_string) 88 except NotImplemented: 89 pass 84 90 table_output.append(' '.join(field_output)) 85 91 if opts.order_with_respect_to: 86 92 table_output.append('%s %s NULL' % (db.db.quote_name('_order'), db.DATA_TYPES['IntegerField']))