django-postgres-extra icon indicating copy to clipboard operation
django-postgres-extra copied to clipboard

Django 5.0 support

Open bufke opened this issue 2 years ago • 14 comments

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.

bufke avatar Dec 06 '23 14:12 bufke

#233 should fix this.

adamantike avatar Jan 02 '24 15:01 adamantike

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

Joeboy avatar Feb 26 '24 12:02 Joeboy

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'

benoit9126 avatar Feb 26 '24 13:02 benoit9126

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

sandeepbol avatar Mar 04 '24 04:03 sandeepbol

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.

sandeepbol avatar Mar 26 '24 05:03 sandeepbol

Hello, is it supported now?

hogking avatar Mar 27 '24 09:03 hogking

😢 😞

sandeepbol avatar Apr 03 '24 11:04 sandeepbol

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

benoit9126 avatar Apr 03 '24 12:04 benoit9126

When will the new release with the 5.0 support come?

sandeepbol avatar Apr 29 '24 06:04 sandeepbol

Almost 6 months since this issue was open :(

sandeepbol avatar May 15 '24 09:05 sandeepbol

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

Mogost avatar May 23 '24 14:05 Mogost

Almost a year, are we going to support Django 5?

sandeepbol avatar Oct 15 '24 13:10 sandeepbol

@sandeepbol consider submitting fixes or fork it. Many of the features here are IMO not very important with current Django. I only use partitioning. If someone wants to collaborate on a partitioning-only fork, let me know. It would be easier to maintain a smaller feature set.

I use it like this for now.

bufke avatar Oct 16 '24 16:10 bufke

I only use it for partitioning these days as well. But aside from initial table creation managing the partitions manually (cronjob) isn't that big of a deal. It'd be nice to have a properly supported package for it, though, but I do not personally have time to commit to that.

Chainfire avatar Nov 29 '24 09:11 Chainfire