sqlalchemy.ext.declarative docs should mention how to set CheckConstraint()'s

Issue #1811 resolved
Former user created an issue

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)

  1. Former user 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?

  2. Mike Bayer repo owner

    i'd rather make the kw dict optional entirely, but that's a different issue. closing this for now.

  3. Log in to comment