From 70edfa229c8bd3d34f11fbfeaf5a7fa6bb1dfff2 Mon Sep 17 00:00:00 2001 From: Chris Withers Date: Sun, 19 May 2013 08:50:06 +0100 Subject: Basic type support for the new range types in postgres 9.2 --- lib/sqlalchemy/dialects/postgresql/base.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/sqlalchemy/dialects/postgresql/base.py') diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 0810e0384..127e1130b 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1150,6 +1150,24 @@ class PGTypeCompiler(compiler.GenericTypeCompiler): def visit_HSTORE(self, type_): return "HSTORE" + def visit_INT4RANGE(self, type_): + return "INT4RANGE" + + def visit_INT8RANGE(self, type_): + return "INT8RANGE" + + def visit_NUMRANGE(self, type_): + return "NUMRANGE" + + def visit_DATERANGE(self, type_): + return "DATERANGE" + + def visit_TSRANGE(self, type_): + return "TSRANGE" + + def visit_TSTZRANGE(self, type_): + return "TSTZRANGE" + def visit_datetime(self, type_): return self.visit_TIMESTAMP(type_) -- cgit v1.2.1 From b2ea2eef5db160183cd4f812b0ce1636d8799b91 Mon Sep 17 00:00:00 2001 From: Chris Withers Date: Tue, 21 May 2013 21:11:35 +0100 Subject: Implement EXCLUDE constraints for postgres. --- lib/sqlalchemy/dialects/postgresql/base.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/sqlalchemy/dialects/postgresql/base.py') 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_): -- cgit v1.2.1 From b2da12e070e9d83bea5284dae11b8e6d4d509818 Mon Sep 17 00:00:00 2001 From: Chris Withers Date: Mon, 10 Jun 2013 13:24:02 +0100 Subject: Documentation for the new range type support. --- lib/sqlalchemy/dialects/postgresql/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/sqlalchemy/dialects/postgresql/base.py') diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 4a6de0ceb..238a8af8f 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -426,7 +426,7 @@ class array(expression.Tuple): An instance of :class:`.array` will always have the datatype :class:`.ARRAY`. The "inner" type of the array is inferred from - the values present, unless the "type_" keyword argument is passed:: + the values present, unless the ``type_`` keyword argument is passed:: array(['foo', 'bar'], type_=CHAR) -- cgit v1.2.1