Fixed #6433 -- Handle some varied PostgreSQL version strings (beta versions and
Windows version strings). Patch from jerickso. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7415 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
6dfe245f02
commit
35afdedbed
|
@ -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 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||
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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue