On Thu, Feb 1, 2018 at 3:27 AM, Chris Withers <ch...@withers.org> wrote: > Hi, > > So, I need to add an exclude constraint to a postgres table which has a > boolean column, but: > > ProgrammingError: (psycopg2.ProgrammingError) data type boolean has no > default operator class for access method "gist" > HINT: You must specify an operator class for the index or define a default > operator class for the data type. > > Sounds like the way to do this is: > > https://www.postgresql.org/message-id/OfficeNetEmail.2b9.8648e2b7c49ce986.144ee6b67a2%40prod2 > > create table xx(b bool, tr tsrange, exclude using gist((b::int) with =, tr > with &&)); > > That, unfortunately makes SQLALchemy's ExcludeConstraint implementation sad: > > sqlalchemy/util/_collections.py", line 194, in __getitem__ > return self._data[key] > KeyError: '(best::int)' > > Before I go and submit a patch to ExcludeConstraint to support expressions > rather than just columns (that looks like a lot of work :-/), how can I just > add a constraint that I supply as text and put in __table_args__ somehow?
just DDL() as always http://docs.sqlalchemy.org/en/latest/core/ddl.html?highlight=ddl#custom-ddl > > cheers, > > Chris > > -- > SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- You received this message because you are subscribed to the Google > Groups "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To post to this group, send email to sqlalchemy@googlegroups.com. > Visit this group at https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.