Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django 5.0 support #232

Open
bufke opened this issue Dec 6, 2023 · 11 comments
Open

Django 5.0 support #232

bufke opened this issue Dec 6, 2023 · 11 comments

Comments

@bufke
Copy link

bufke commented Dec 6, 2023

Hello, Django 5.0 is released. Is there anything you need help on to support it? Currently this package is marked as Django<5.0.

@adamantike
Copy link

#233 should fix this.

@Joeboy
Copy link

Joeboy commented Feb 26, 2024

I think django 5.0.x is supported now? Maybe this can be closed?

@benoit9126
Copy link

benoit9126 commented Feb 26, 2024

I have a remaining problem related to Django 5.0 for tests only when I use pytest with the --create-db option. There is a connection to the database called __no_db__. A field is missing to the DatabaseOperations ( django.db.backends.postgresql.operations.DatabaseOperations). The issue does not appear with Django 4.* and comes from the class psqlextra.backend.base.DatabaseWrapper.

Here is the stack trace:

test setup failed
request = <SubRequest 'django_db_setup' for <Function test_retrieve_action[Database1]>>
django_test_environment = None
django_db_blocker = <pytest_django.plugin.DjangoDbBlocker object at 0x7f80117aecf0>
django_db_use_migrations = False, django_db_keepdb = True
django_db_createdb = True, django_db_modify_db_settings = None

    @pytest.fixture(scope="session")
    def django_db_setup(
        request: pytest.FixtureRequest,
        django_test_environment: None,
        django_db_blocker: DjangoDbBlocker,
        django_db_use_migrations: bool,
        django_db_keepdb: bool,
        django_db_createdb: bool,
        django_db_modify_db_settings: None,
    ) -> Generator[None, None, None]:
        """Top level fixture to ensure test databases are available"""
        from django.test.utils import setup_databases, teardown_databases
    
        setup_databases_args = {}
    
        if not django_db_use_migrations:
            _disable_migrations()
    
        if django_db_keepdb and not django_db_createdb:
            setup_databases_args["keepdb"] = True
    
        with django_db_blocker.unblock():
>           db_cfg = setup_databases(
                verbosity=request.config.option.verbose,
                interactive=False,
                **setup_databases_args,
            )

../../.pyenv/versions/myenv/lib/python3.12/site-packages/pytest_django/fixtures.py:139: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../.pyenv/versions/myenv/lib/python3.12/site-packages/django/test/utils.py:203: in setup_databases
    connection.creation.create_test_db(
../../.pyenv/versions/myenv/lib/python3.12/site-packages/django/db/backends/base/creation.py:62: in create_test_db
    self._create_test_db(verbosity, autoclobber, keepdb)
../../.pyenv/versions/myenv/lib/python3.12/site-packages/django/db/backends/base/creation.py:199: in _create_test_db
    with self._nodb_cursor() as cursor:
../../.pyenv/versions/3.12.1/lib/python3.12/contextlib.py:137: in __enter__
    return next(self.gen)
../../.pyenv/versions/myenv/lib/python3.12/site-packages/django/db/backends/postgresql/base.py:402: in _nodb_cursor
    with super()._nodb_cursor() as cursor:
../../.pyenv/versions/3.12.1/lib/python3.12/contextlib.py:137: in __enter__
    return next(self.gen)
../../.pyenv/versions/myenv/lib/python3.12/site-packages/django/db/backends/base/base.py:706: in _nodb_cursor
    conn = self.__class__({**self.settings_dict, "NAME": None}, alias=NO_DB_ALIAS)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <DatabaseWrapper vendor='postgresql' alias='__no_db__'>
args = ({'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_HEALTH_CHECKS': False, 'CONN_MAX_AGE': 0, ...},)
kwargs = {'alias': '__no_db__'}

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
    
        # Some base back-ends such as the PostGIS back-end don't properly
        # set `ops_class` and `introspection_class` and initialize these
        # classes themselves.
        #
        # This can lead to broken functionality. We fix this automatically.
    
        if not isinstance(self.introspection, self.introspection_class):
            self.introspection = self.introspection_class(self)
    
        if not isinstance(self.ops, self.ops_class):
            self.ops = self.ops_class(self)
    
>       for expected_compiler_class in self.ops.compiler_classes:
E       AttributeError: 'DatabaseOperations' object has no attribute 'compiler_classes'

@sandeepbol
Copy link

When are we planning this release? This is blocking our efforts to migrate to Django 5.

@sandeepbol
Copy link

Guys, it has been almost 3 weeks without update on this. Is there a plan or at least some timeline would help us plan things better.

@hogking
Copy link

hogking commented Mar 27, 2024

Hello, is it supported now?

@sandeepbol
Copy link

sandeepbol commented Apr 3, 2024

😢 😞

@benoit9126
Copy link

To temporarily solve the problem I have above, I simply add

from django.db.backends.postgresql.operations import DatabaseOperations

DatabaseOperations.compiler_classes = []

to my conftest.py which is only used when using pytest.

The current RC release of postgres-extra works fine outside tests (disclaimer: I do not use all the features of the library).

@sandeepbol
Copy link

When will the new release with the 5.0 support come?

@sandeepbol
Copy link

Almost 6 months since this issue was open :(

@Mogost
Copy link
Contributor

Mogost commented May 23, 2024

@Photonios is there anything that should be fixed for having a release with django 5.0 support?
I see that dependency in setup.py current code is already relaxed. And the last tests run is all green.

UPD: Also it seems to me that the upper limit could be removed altogether. That way the project will probably be more likely to receive patches from the community with compatibility fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants