Skip to content

Commit

Permalink
Merge pull request #98 from LorenzoProd/psycopg3-compatibility
Browse files Browse the repository at this point in the history
Fix: Ensure compatibility with Psycopg 3 by updating server_version access
  • Loading branch information
M1ha-Shvn authored Jun 30, 2024
2 parents e77c533 + 3567e2c commit 915e094
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name='django-pg-bulk-update',
version='3.7.2',
version='3.7.3',
packages=['django_pg_bulk_update'],
package_dir={'': 'src'},
url='https://github.com/M1hacka/django-pg-bulk-update',
Expand Down
7 changes: 6 additions & 1 deletion src/django_pg_bulk_update/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ def get_postgres_version(using=None, as_tuple=True):
A single number major*10000 + minor*100 + revision if false.
"""
conn = connection if using is None else connections[using]
num = conn.cursor().connection.server_version
try:
# server_version moved to ConnectionInfo class in psycopg 3.0
num = conn.cursor().connection.info.server_version
except AttributeError:
# server_version is directly available in the Connection class in psycopg 2.x
num = conn.cursor().connection.server_version
return (int(num / 10000), int(num % 10000 / 100), num % 100) if as_tuple else num


Expand Down

0 comments on commit 915e094

Please sign in to comment.