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

Support psycopg 3 #130

Open
bufke opened this issue Mar 22, 2023 · 5 comments · May be fixed by #131
Open

Support psycopg 3 #130

bufke opened this issue Mar 22, 2023 · 5 comments · May be fixed by #131

Comments

@bufke
Copy link
Contributor

bufke commented Mar 22, 2023

psycopg 3 is supported in Django 4.2. However it's interface has breaking changes.

File "/usr/local/lib/python3.10/site-packages/bitfield/types.py", line 261, in <module>
  Database.extensions.register_adapter(Bit, lambda x: Database.extensions.AsIs(int(x)))
AttributeError: module 'psycopg' has no attribute 'extensions'

extensions no longer exists. It's replacement is documented here.

I might be able to contribute a fix for this, however I'd have to learn about psycopg.

@bufke
Copy link
Contributor Author

bufke commented Mar 23, 2023

In some limited testing, it appears that removing these lines from types.py fixes the problem.

    Database.extensions.register_adapter(Bit, lambda x: Database.extensions.AsIs(int(x)))
    Database.extensions.register_adapter(BitHandler, lambda x: Database.extensions.AsIs(int(x)))

No adaption is required at all perhaps. I played around with django admin and was able to check and uncheck the bitfield options.

Are there instructions on how to run tests locally?

bufke added a commit to bufke/django-bitfield that referenced this issue Mar 23, 2023
@bufke bufke linked a pull request Mar 23, 2023 that will close this issue
bufke added a commit to bufke/django-bitfield that referenced this issue Apr 5, 2023
@kjumybit
Copy link

Hi team,

I'm running my Django apps using pscopg3. With reference to Django 4.2 release notes

Support for psycopg2 is likely to be deprecated and removed at some point in the future.

supporting pscopg3 is very helpful and required for migration existing apps.

@alvarogf97
Copy link

Hitl there,

are those changes working well? It seems that the repository is now unmaintained.

Thanks in advance

@timabbott
Copy link
Collaborator

The repository is lightly maintained; we merge well-tested PRs, but aren't actively adding new features.

@bufke
Copy link
Contributor Author

bufke commented Nov 21, 2024

I'm using a subset of the features from this on my project, GlitchTip - see source. It works for me with psycopg 3. I'm aware from my attempts to fix it that some features do not work. I was not able to get my PR in a good enough state to merge.

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

Successfully merging a pull request may close this issue.

4 participants