Skip to content

Commit

Permalink
Fixed #6433 -- Handle some varied PostgreSQL version strings (beta ve…
Browse files Browse the repository at this point in the history
…rsions and

Windows version strings). Patch from jerickso.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7415 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
malcolmt committed Apr 13, 2008
1 parent 6dfe245 commit 35afded
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion django/db/backends/postgresql/operations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import re

from django.db.backends import BaseDatabaseOperations

server_version_re = re.compile(r'PostgreSQL (\d{1,2})\.(\d{1,2})\.?(\d{1,2})?')

# This DatabaseOperations class lives in here instead of base.py because it's
# used by both the 'postgresql' and 'postgresql_psycopg2' backends.

Expand All @@ -12,7 +16,11 @@ def _get_postgres_version(self):
from django.db import connection
cursor = connection.cursor()
cursor.execute("SELECT version()")
self._postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')]
version_string = cursor.fetchone()[0]
m = server_version_re.match(version_string)
if not m:
raise Exception('Unable to determine PostgreSQL version from version() function string: %r' % version_string)
self._postgres_version = [int(val) for val in m.groups() if val]
return self._postgres_version
postgres_version = property(_get_postgres_version)

Expand Down

0 comments on commit 35afded

Please sign in to comment.