]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
base supports_native_enum on 8.3 or greater
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 21 Jan 2010 03:41:35 +0000 (03:41 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 21 Jan 2010 03:41:35 +0000 (03:41 +0000)
lib/sqlalchemy/dialects/postgresql/base.py

index 2c8f896e9c6f1ea5a6e94132f68c97fd1c250404..bc5459f3a3c00bbf97f45703a40149b1315b4973 100644 (file)
@@ -450,7 +450,7 @@ class PGTypeCompiler(compiler.GenericTypeCompiler):
         return self.visit_TIMESTAMP(type_)
     
     def visit_enum(self, type_):
-        if not type_.native_enum:
+        if not type_.native_enum or not self.dialect.supports_native_enum:
             return super(PGTypeCompiler, self).visit_enum(type_)
         else:
             return self.visit_ENUM(type_)
@@ -589,7 +589,11 @@ class PGDialect(default.DefaultDialect):
         super(PGDialect, self).initialize(connection)
         self.implicit_returning = self.server_version_info > (8, 2) and \
                                         self.__dict__.get('implicit_returning', True)
-        
+        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]
+            
     def visit_pool(self, pool):
         if self.isolation_level is not None:
             class SetIsolationLevel(object):
@@ -1047,6 +1051,9 @@ class PGDialect(default.DefaultDialect):
         return indexes
 
     def _load_enums(self, connection):
+        if not self.supports_native_enum:
+            return {}
+
         ## Load data types for enums:
         SQL_ENUMS = """
             SELECT t.typname as "name",