why UniqueConstraint doesn't work in flask_sqlalchemy
An instance of UniqueConstraint
is iterable and in this case seems to stop iteration immediately, so
tuple(db.UniqueConstraint('name', 'address'))
results in an empty tuple, when you wanted a tuple that contains 1 item, the constraint instance. Use
__table_args__ = (db.UniqueConstraint('name', 'address'), )
or any other variation instead. As to why the latter form does not work, you must apply table-level constraint objects using __table_args__
in declarative.