#34486: SearchHeadline crashes without an active connection.
----------------------------------+------------------------------------
Reporter: Scott Macpherson | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 4.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Comment (by Mariusz Felisiak):
Replying to [comment:8 Scott Macpherson]:
> I'd be happy to. Are you able to give me some pointers on replicating
the behaviour we're seeing from inside `TestCase`?
>
> I've been mucking about with `TransactionTestCase` rather than
`TestCase`, and I can get things into a state where
`connection.connection` inside `mogrify` returns an idle connection rather
than one that's in a transaction, but that's not far enough to replicate
this.
Since the real issue is in `compose_sql()`, I'd add a backend-specific
test, e.g.
{{{#!diff
diff --git a/tests/backends/postgresql/tests.py
b/tests/backends/postgresql/tests.py
index 9c4512be24..82df344139 100644
--- a/tests/backends/postgresql/tests.py
+++ b/tests/backends/postgresql/tests.py
@@ -420,3 +420,11 @@ class Tests(TestCase):
with self.assertRaisesMessage(NotSupportedError, msg):
connection.check_database_version_supported()
self.assertTrue(mocked_get_database_version.called)
+
+ def test_compose_sql_no_connection(self):
+ new_connection = connection.copy()
+ # compose_sql() should open a new connection.
+ try:
+ self.assertEqual(new_connection.ops.compose_sql("SELECT %s",
["test"]), "SELECT 'test'")
+ finally:
+ new_connection.close()
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34486#comment:9>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701877a135949-b83c6d02-8ea3-4c6c-8753-ceae4182e5b1-000000%40eu-central-1.amazonses.com.