-
Notifications
You must be signed in to change notification settings - Fork 104
Support psycopg3 #208
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 psycopg3 #208
Conversation
This could be fixed by adding a new dimension to the Tox configuration file which already runs the tests against multiple Django and Python versions. See: https://github.com/SectorLabs/django-postgres-extra/blob/master/tox.ini |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
# create a mapping between column names and column value | ||
return [ | ||
{ | ||
column.name: row[column_index] | ||
for column_index, column in enumerate(cursor.description) | ||
for column_index, column in enumerate(description) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this change. How is aliasing it on line 190 changing how this works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the with cursor
now cleans up the data on the cursor on exit. So cusror.description
ends up being None. So we just need to read it before the with block exits
f829c93
to
118bf09
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
.circleci/config.yml
Outdated
@@ -42,6 +42,12 @@ commands: | |||
environment: | |||
DATABASE_URL: 'postgres://psqlextra:psqlextra@localhost:5432/psqlextra' | |||
|
|||
- run: | |||
name: Run tests psycopg3 | |||
command: tox -e 'py<< parameters.pyversion >>-dj{<< parameters.djversions >>}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this install psycopg3? I don't see any references in tox.ini
to psycopg3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh sorry, this was me trying to figure tox/circle out
Right now the djversion=42 uses psycopg3 (though It means that it does not test psycopg2)
@@ -11,6 +11,7 @@ deps = | |||
dj32: Django~=3.2.0 | |||
dj40: Django~=4.0.0 | |||
dj41: Django~=4.1.0 | |||
dj42: .[psycopg3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means the tests don't run against psycopg2 anymore. I will patch this up after merging this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added this. Tests run against psycopg 2.8, 2.9 and 3.0 now with all supported Django versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@snuderl You can try it out in |
Yup. Works with our codebase! |
I was also experiencing this issue, and bumping to one of the current RC releases fixed it. Looking for a new release to unpin our dependency from RC! 🙂 |
Very minor changes needed to support this.
I am not sure what the best way to add tests for this would be, as ideally test would ran against both psycopg2 and psycopg3.
Edit:
Set up the tests.
P.S.
Really sweet testing setup.