1. Michael Bayer
  2. alembic

Issues

Issue #156 resolved

Alembic doesn't throw TypeError on unexpected keyword arguments

Frozenball
created an issue

Alembic shouldn't just ignore keyword arguments that are not used. I recently typod "postgesql_where" and to my surprise, Alembic just went along with it and created an invalid index.

Case example:

op.create_index(
        "uq_index_user_email_reseller_is_null",
        "user",
        ['email'],
        postresql_where=text("reseller_id IS NULL"),
        unique=True
    )

What I expected:

TypeError: op.create_index() got an unexpected keyword argument 'postresql_where'

Comments (4)

  1. Michael Bayer repo owner

    this isn't really possible, because technically SQLAlchemy can't know that there isn't a 3rd party dialect called "postresql" in use. Other kwargs that don't take the form "<dialectname>_<argument>" are rejectable on the SQLAlchemy side, right now this logic takes effect for tables and constraints but is missing on the index side. but wouldn't help this case.

  2. Log in to comment