diff options
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/ext.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/ext.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/ext.py b/lib/sqlalchemy/dialects/postgresql/ext.py index 78d9a96b6..4c8c3fc22 100644 --- a/lib/sqlalchemy/dialects/postgresql/ext.py +++ b/lib/sqlalchemy/dialects/postgresql/ext.py @@ -114,7 +114,8 @@ class ExcludeConstraint(ColumnCollectionConstraint): const = ExcludeConstraint( (Column('period'), '&&'), (Column('group'), '='), - where=(Column('group') != 'some group') + where=(Column('group') != 'some group'), + ops={'group': 'my_operator_class'} ) The constraint is normally embedded into the :class:`_schema.Table` @@ -133,7 +134,8 @@ class ExcludeConstraint(ColumnCollectionConstraint): (some_table.c.period, '&&'), (some_table.c.group, '='), where=some_table.c.group != 'some group', - name='some_table_excl_const' + name='some_table_excl_const', + ops={'group': 'my_operator_class'} ) ) @@ -171,6 +173,19 @@ class ExcludeConstraint(ColumnCollectionConstraint): If set, emit WHERE <predicate> when issuing DDL for this constraint. + :param ops: + Optional dictionary. Used to define operator classes for the + elements; works the same way as that of the + :ref:`postgresql_ops <postgresql_operator_classes>` + parameter specified to the :class:`_schema.Index` construct. + + .. versionadded:: 1.3.21 + + .. seealso:: + + :ref:`postgresql_operator_classes` - general description of how + PostgreSQL operator classes are specified. + """ columns = [] render_exprs = [] @@ -209,6 +224,8 @@ class ExcludeConstraint(ColumnCollectionConstraint): if where is not None: self.where = coercions.expect(roles.StatementOptionRole, where) + self.ops = kw.get("ops", {}) + def _set_parent(self, table, **kw): super(ExcludeConstraint, self)._set_parent(table) |