diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2013-06-22 07:47:02 -0700 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-22 11:27:09 -0400 |
| commit | f52d45672b0206a866258aa5291096816c8563b4 (patch) | |
| tree | b49466954f8778b32467e227f6a5ee93f4dec298 /lib/sqlalchemy/dialects/postgresql/base.py | |
| parent | c05ef592bfaa4f2074fb80d048288fcb9e11679a (diff) | |
| download | sqlalchemy-f52d45672b0206a866258aa5291096816c8563b4.tar.gz | |
Merge pull request #5 from cjw296/pg-ranges
Support for Postgres range types.
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 8c9af5bcf..e1fc9e211 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -444,7 +444,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) @@ -1142,6 +1142,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_): @@ -1168,6 +1184,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_) |
