summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
authorChris Withers <chris@simplistix.co.uk>2013-05-21 21:11:35 +0100
committerChris Withers <chris@simplistix.co.uk>2013-06-10 12:09:56 +0100
commitb2ea2eef5db160183cd4f812b0ce1636d8799b91 (patch)
tree88b4b352a463c278e587fa5c13749685639b18b0 /lib/sqlalchemy/dialects/postgresql/base.py
parentf4020282b798ea510e6aafda779ab33c692c0120 (diff)
downloadsqlalchemy-b2ea2eef5db160183cd4f812b0ce1636d8799b91.tar.gz
Implement EXCLUDE constraints for postgres.
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 127e1130b..4a6de0ceb 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -1124,6 +1124,22 @@ class PGDDLCompiler(compiler.DDLCompiler):
text += " WHERE " + where_compiled
return text
+ def visit_exclude_constraint(self, constraint):
+ text = ""
+ if constraint.name is not None:
+ text += "CONSTRAINT %s " % \
+ self.preparer.format_constraint(constraint)
+ elements = []
+ for c in constraint.columns:
+ op = constraint.operators[c.name]
+ elements.append(self.preparer.quote(c.name, c.quote)+' WITH '+op)
+ text += "EXCLUDE USING %s (%s)" % (constraint.using, ', '.join(elements))
+ if constraint.where is not None:
+ sqltext = sql_util.expression_as_ddl(constraint.where)
+ text += ' WHERE (%s)' % self.sql_compiler.process(sqltext)
+ text += self.define_constraint_deferrability(constraint)
+ return text
+
class PGTypeCompiler(compiler.GenericTypeCompiler):
def visit_INET(self, type_):