From: Mike Bayer Date: Tue, 30 Nov 2010 18:55:17 +0000 (-0500) Subject: - Fixed bug whereby KeyError would occur with non-ENUM X-Git-Tag: rel_0_6_6~31^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=582b12152eb80bad865326dcda2f0a4fc51042d6;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed bug whereby KeyError would occur with non-ENUM supported PG versions after a pool dispose+recreate would occur, [ticket:1989] --- diff --git a/CHANGES b/CHANGES index 12937f5ee4..d1115e7a64 100644 --- 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 diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 7b1a97c325..9e693cbca9 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -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: diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index 92c0894806..9a93ec7dc8 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -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)