(SQLAlchemy 1.0.11)

I'm trying to figure out how to define a unique constraint from within the 
model when using declarative_base.

class User(Base):
    __tablename__ = 'users'

    # This obviously doesn't work
    __table_args__ = (
        UniqueConstraint("data->'email'")
    )

    data = Column(JSON)


Clearly that is the wrong syntax, but is it possible to do via SQLAlchemy 
constructs and not directly creating the constraint with the engine? Our 
app is already tied to Postgres at this point, but it'd still be nice to 
keep everything in the model.

-- 
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.

Reply via email to