Opened 10 months ago

Last modified 10 months ago

#35226 closed Bug

Copying a connection with a new alias fails — at Initial Version

Reported by: Florian Apolloner Owned by: nobody
Component: Testing framework Version: dev
Severity: Release blocker Keywords:
Cc: Florian Apolloner, David Wobrock Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

While working on connection pooling for postgres I ran into the following regression (since https://github.com/django/django/commit/8fb0be3500cc7519a56985b1b6f415d75ac6fedb ):

from django.db import connection
from django.test import TestCase


class Test(TestCase):
    def test_something(self):
        new_connection = connection.copy("asd")
        with new_connection.cursor() as cursor:
            print(cursor.execute("SELECT 1").fetchall())

On 5.0 this works fine, on main this fails with:

django.test.testcases.DatabaseOperationForbidden: Database threaded connections to 'asd' are not allowed in this test. Add 'asd' to test_regression.Test.databases to ensure proper test isolation and silence this failure.

I cannot really add this to databases since this is a dynamically created database. I am opening this as release blocker so it doesn't get lost (I might be holding it wrong though)

Change History (0)

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