SectorLabs / django-postgres-extra

Bringing all of PostgreSQL's awesomeness to Django.
MIT License
692 stars 94 forks source link

Django 5.0 support #232

Open bufke opened 9 months ago

bufke commented 9 months ago

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 commented 8 months ago

233 should fix this.

Joeboy commented 6 months ago

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

benoit9126 commented 6 months ago

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 commented 6 months ago

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

sandeepbol commented 5 months ago

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 commented 5 months ago

Hello, is it supported now?

sandeepbol commented 5 months ago

😢 😞

benoit9126 commented 5 months ago

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 commented 4 months ago

When will the new release with the 5.0 support come?

sandeepbol commented 3 months ago

Almost 6 months since this issue was open :(

Mogost commented 3 months ago

@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.