summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2009-12-06 19:51:10 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2009-12-06 19:51:10 +0000
commitf9cb6f5834fb1acf4460fd9bb6b72f8c76f8c36c (patch)
treed2ec1ec2f53858f927db3059cc0cf9ba6a8034d5 /lib/sqlalchemy/dialects/postgresql
parent4ca12d76bd8580d56c4ec1f7ed95c0e37a4c281a (diff)
downloadsqlalchemy-f9cb6f5834fb1acf4460fd9bb6b72f8c76f8c36c.tar.gz
- reworked the DDL generation of ENUM and similar to be more platform agnostic.
Uses a straight CheckConstraint with a generic expression. Preparing for boolean constraint in [ticket:1589] - CheckConstraint now accepts SQL expressions, though support for quoting of values will be very limited. we don't want to get into formatting dates and such.
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index e31cc7d91..d0a87d282 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -74,7 +74,7 @@ import re
from sqlalchemy import schema as sa_schema
from sqlalchemy import sql, schema, exc, util
from sqlalchemy.engine import base, default, reflection
-from sqlalchemy.sql import compiler, expression
+from sqlalchemy.sql import compiler, expression, util as sql_util
from sqlalchemy.sql import operators as sql_operators
from sqlalchemy import types as sqltypes
@@ -348,10 +348,6 @@ class PGDDLCompiler(compiler.DDLCompiler):
colspec += " NOT NULL"
return colspec
- def visit_enum_constraint(self, constraint):
- if not constraint.type.native_enum:
- return super(PGDDLCompiler, self).visit_enum_constraint(constraint)
-
def visit_create_enum_type(self, create):
type_ = create.element
@@ -387,11 +383,9 @@ class PGDDLCompiler(compiler.DDLCompiler):
whereclause = None
if whereclause is not None:
- compiler = self._compile(whereclause, None)
- # this might belong to the compiler class
- inlined_clause = str(compiler) % dict(
- [(key,bind.value) for key,bind in compiler.binds.iteritems()])
- text += " WHERE " + inlined_clause
+ whereclause = sql_util.expression_as_ddl(whereclause)
+ where_compiled = self.sql_compiler.process(whereclause)
+ text += " WHERE " + where_compiled
return text
@@ -530,6 +524,8 @@ class PGDialect(default.DefaultDialect):
max_identifier_length = 63
supports_sane_rowcount = True
+ supports_native_enum = True
+
supports_sequences = True
sequences_optional = True
preexecute_autoincrement_sequences = True