Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #6433 -- Handle some varied PostgreSQL version strings (beta ve…

…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...
commit 35afdedbed6345a3b078ebea0a105718109d7fda 1 parent 6dfe245
@malcolmt malcolmt authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 django/db/backends/postgresql/operations.py
View
10 django/db/backends/postgresql/operations.py
@@ -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.
@@ -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)

0 comments on commit 35afded

Please sign in to comment.
Something went wrong with that request. Please try again.