Naming conventions example should use columns_0_name

Issue #3345 new
Thomas Tanner created an issue

The example http://docs.sqlalchemy.org/en/latest/core/constraints.html#configuring-constraint-naming-conventions

convention = {
  "ix": 'ix_%(column_0_label)s',
  "uq": "uq_%(table_name)s_%(column_0_name)s",
  "ck": "ck_%(table_name)s_%(constraint_name)s",
  "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
  "pk": "pk_%(table_name)s"
}

should be changed to "ck": "ck_%(table_name)s_%(column_0_name)s", Otherwise unnamed constraints (for example, Boolean) raise

sqlalchemy.exc.InvalidRequestError: Naming convention including %(constraint_name)s token requires that constraint is explicitly named.

Comments (5)

  1. Mike Bayer repo owner

    in fact I'd rather there be additional documentation here for check constraints, as there are different options to go with. the Boolean and Enum objects encourage a constraint name to be passed to their constructors.

  2. Wichert Akkerman

    FWIW I ran into this one as well. I got a pull request for pyramid_sqlalchemy which set a default naming convention (as recommended by the alembic documentation), but after merging that all my tests started failing immediately when trying to use boolean columns on SQLite.

  3. Log in to comment