]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed the psycopg2_version parsing in the
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 18 Apr 2011 16:38:08 +0000 (12:38 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 18 Apr 2011 16:38:08 +0000 (12:38 -0400)
psycopg2 dialect.

CHANGES
lib/sqlalchemy/dialects/postgresql/psycopg2.py
test/dialect/test_postgresql.py

diff --git a/CHANGES b/CHANGES
index a781307b429deb88d8f07009c2985d65c3b85941..72fc038c126ed43a0e19116c14546b8df6411af1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -15,6 +15,10 @@ CHANGES
     fixed up some of the error messages tailored
     in [ticket:2069]
 
+- postgresql
+  - Fixed the psycopg2_version parsing in the 
+    psycopg2 dialect.
+
 0.7.0b4
 =======
 - general
index 2fceb7f17d499aaf3ab0eaec1cd32a84c4777c37..2a3b4297c3b559e5f9c543ec3a60e8eef8c9b6d6 100644 (file)
@@ -252,10 +252,13 @@ class PGDialect_psycopg2(PGDialect):
         self.use_native_unicode = use_native_unicode
         self.supports_unicode_binds = use_native_unicode
         if self.dbapi and hasattr(self.dbapi, '__version__'):
-            m = re.match(r'(\d+)\.(\d+)\.(\d+)?', 
+            m = re.match(r'(\d+)\.(\d+)(?:\.(\d+))?', 
                                 self.dbapi.__version__)
             if m:
-                self.psycopg2_version = tuple(map(int, m.group(1, 2, 3)))
+                self.psycopg2_version = tuple(
+                                            int(x) 
+                                            for x in m.group(1, 2, 3) 
+                                            if x is not None)
 
     @classmethod
     def dbapi(cls):
index e0128a77f261cefbfc3096e7a7ab589e814733ea..de71695793cecffca845b638e439a804a8db1023 100644 (file)
@@ -1245,6 +1245,12 @@ class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
             eq_(testing.db.dialect._get_server_version_info(MockConn(string)),
                 version)
 
+    @testing.only_on('postgresql+psycopg2', 'psycopg2-specific feature')
+    def test_psycopg2_version(self):
+        v = testing.db.dialect.psycopg2_version
+        assert testing.db.dialect.dbapi.__version__.\
+                    startswith(".".join(str(x) for x in v))
+
     @testing.only_on('postgresql+psycopg2', 'psycopg2-specific feature')
     def test_notice_logging(self):
         log = logging.getLogger('sqlalchemy.dialects.postgresql')