Opened 11 years ago

Last modified 9 years ago

#22377 closed Bug

SQL Logging throws an exception when fields have utf-8 characters — at Initial Version

Reported by: rolanvc@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.9
Severity: Normal Keywords: sql logging for utf-8
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In django/db/backends/util.py, in CursorDebugWrapper.execute, the line:

logger.debug('(%.3f) %s; args=%s' % (duration, sql, params),

extra={'duration': duration, 'sql': sql, 'params': params}

)

throws a "UnicodeDecodeError:ascii codec .... " when calling model.save() when some fields have utf-8/non-ascii values. My only workaround is to modify it to:

logger.debug('(%.3f) %s; args=%s' % (duration, sql.decode('utf-8'), params),

extra={'duration': duration, 'sql': sql, 'params': params}

)

I'm hoping there's a better and more elegant way that I could use.

Thanks!
=)

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top