diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 9de3287..f381d48 100644
a
|
b
|
class DatabaseOperations(BaseDatabaseOperations):
|
238 | 238 | # With MySQLdb, cursor objects have an (undocumented) "_last_executed" |
239 | 239 | # attribute where the exact query sent to the database is saved. |
240 | 240 | # See MySQLdb/cursors.py in the source distribution. |
241 | | return cursor._last_executed |
| 241 | return cursor._last_executed.decode('utf-8') |
242 | 242 | |
243 | 243 | def no_limit_value(self): |
244 | 244 | # 2**64 - 1, as recommended by the MySQL documentation |
diff --git a/django/db/backends/postgresql_psycopg2/operations.py b/django/db/backends/postgresql_psycopg2/operations.py
index 46b464b..88a413b 100644
a
|
b
|
class DatabaseOperations(BaseDatabaseOperations):
|
193 | 193 | def last_executed_query(self, cursor, sql, params): |
194 | 194 | # http://initd.org/psycopg/docs/cursor.html#cursor.query |
195 | 195 | # The query attribute is a Psycopg extension to the DB API 2.0. |
196 | | return cursor.query |
| 196 | return cursor.query.decode('utf-8') |
197 | 197 | |
198 | 198 | def return_insert_id(self): |
199 | 199 | return "RETURNING %s", () |
diff --git a/tests/regressiontests/logging_tests/tests.py b/tests/regressiontests/logging_tests/tests.py
index 4ae3c1b..d443101 100644
a
|
b
|
|
| 1 | # -*- encoding: utf-8 -*- |
1 | 2 | from __future__ import unicode_literals |
2 | 3 | |
3 | 4 | import copy |
… |
… |
class AdminEmailHandlerTest(TestCase):
|
252 | 253 | |
253 | 254 | self.assertEqual(len(mail.outbox), 1) |
254 | 255 | self.assertEqual(mail.outbox[0].subject, expected_subject) |
| 256 | |
| 257 | class RequestLoggingTest(TestCase): |
| 258 | @override_settings(DEBUG=True) |
| 259 | def test_sql_logging(self): |
| 260 | """ |
| 261 | Test that sql logging of last executed query doesn't produce decoding |
| 262 | error with Unicode caracters (#18461) |
| 263 | """ |
| 264 | from django.contrib.auth.models import User |
| 265 | q = list(User.objects.filter(last_name='й')) |