mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #35021 -- Fixed capturing queries when using client-side parameters binding with psycopg 3+.
This commit is contained in:
parent
177e649396
commit
4426b1a72d
4 changed files with 30 additions and 3 deletions
|
@ -211,6 +211,16 @@ class ExecuteWrapperTests(TestCase):
|
|||
self.assertEqual(connection.execute_wrappers, [])
|
||||
self.assertEqual(connections["other"].execute_wrappers, [])
|
||||
|
||||
def test_wrapper_debug(self):
|
||||
def wrap_with_comment(execute, sql, params, many, context):
|
||||
return execute(f"/* My comment */ {sql}", params, many, context)
|
||||
|
||||
with CaptureQueriesContext(connection) as ctx:
|
||||
with connection.execute_wrapper(wrap_with_comment):
|
||||
list(Person.objects.all())
|
||||
last_query = ctx.captured_queries[-1]["sql"]
|
||||
self.assertTrue(last_query.startswith("/* My comment */"))
|
||||
|
||||
|
||||
class ConnectionHealthChecksTests(SimpleTestCase):
|
||||
databases = {"default"}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue