sqlalchemy.ext.declarative docs should mention how to set CheckConstraint()'s
Issue #1811
resolved
There should be an example how to set CheckConstraint when using declarative_base extension as it doesn't work as intuitively as expected:
__table_args__ = (CheckConstraint(...))
I guess simple example describing how to add them would be nice:
__table_args__ = ( CheckConstraint(...), {})
Comments (3)
-
repo owner -
Account Deleted Nope, the issue was more that when I only have one constraint to add, I also have to specify an empty dict after it ;)
Now that I read that part again I finally noticed the: "Note that the keyword parameters dictionary is required in the tuple form even if empty."
Maybe add a simple example after this note?
-
repo owner - changed status to wontfix
i'd rather make the kw dict optional entirely, but that's a different issue. closing this for now.
- Log in to comment
there's an example of both
ForeignKeyConstraint
andUniqueConstraint
here, http://www.sqlalchemy.org/docs/reference/ext/declarative.html#table-configuration , accompanied by the text "allows positional arguments to be specified as well (usually constraints)" .... isCheckConstraint
so different ?