handle conversion of None to null

This commit is contained in:
Jeremy Carbaugh 2010-03-09 13:00:37 -05:00 committed by James Turk
parent f2d36f0d04
commit dcb0287a79

View File

@ -137,10 +137,13 @@ class SqlDumpEmitter(Emitter):
table_name, '`,`'.join(fieldnames))
def quote(self, item):
if not isinstance(item, ('unicode','str')):
return "%s" % item
if item is None:
return "null"
elif isinstance(item, (unicode, str)):
item = item.replace("\\","\\\\").replace("'","\\'").replace(chr(0),'0')
return "'%s'" % item
else:
return "%s" % item
def emit_record(self, record):
quoted_data = [self.quote(record[field]) for field in self._fieldnames]