]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed bug whereby KeyError would occur with non-ENUM
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 30 Nov 2010 18:55:17 +0000 (13:55 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 30 Nov 2010 18:55:17 +0000 (13:55 -0500)
supported PG versions after a pool dispose+recreate
would occur, [ticket:1989]

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

diff --git a/CHANGES b/CHANGES
index 12937f5ee4ca8f2c2639026dbd20704c112a1fe3..d1115e7a641352f6b06a62480434f7885e2216db 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -82,7 +82,11 @@ CHANGES
     and return values as Python UUID() objects rather than
     strings.  Currently, the UUID type is only known to 
     work with psycopg2.  [ticket:1956]
-        
+
+  - Fixed bug whereby KeyError would occur with non-ENUM 
+    supported PG versions after a pool dispose+recreate
+    would occur, [ticket:1989]
+    
 - mysql
   - Fixed error handling for Jython + zxjdbc, such that 
     has_table() property works again.  Regression from
index 7b1a97c325ef87380368d50d46cddaa07a2e703b..9e693cbca90dc2779dfcb6ea6db68bc5608a839b 100644 (file)
@@ -770,7 +770,10 @@ class PGDialect(default.DefaultDialect):
         self.supports_native_enum = self.server_version_info >= (8, 3)
         if not self.supports_native_enum:
             self.colspecs = self.colspecs.copy()
-            del self.colspecs[ENUM]
+            # pop base Enum type
+            self.colspecs.pop(sqltypes.Enum, None)
+            # psycopg2, others may have placed ENUM here as well
+            self.colspecs.pop(ENUM, None)
 
     def on_connect(self):
         if self.isolation_level is not None:
index 92c0894806a303dca1c718febf37b9b230b91d4b..9a93ec7dc8d6f98240020943fcb7a7f07ad74e1c 100644 (file)
@@ -411,6 +411,24 @@ class EnumTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
             metadata.drop_all()
             assert not testing.db.dialect.has_type(testing.db,
                     'fourfivesixtype')
+    
+    def test_no_support(self):
+        def server_version_info(self):
+            return (8, 2)
+            
+        e = engines.testing_engine()
+        dialect = e.dialect
+        dialect._get_server_version_info = server_version_info
+        
+        assert dialect.supports_native_enum
+        e.connect()
+        assert not dialect.supports_native_enum
+        
+        # initialize is called again on new pool
+        e.dispose()
+        e.connect()
+        assert not dialect.supports_native_enum
+        
 
     def test_reflection(self):
         metadata = MetaData(testing.db)