You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Accept deferrable kwarg for schema editor SQL (#86)
This follows Django 3.1.x's lead in adding `deferrable` as a keyword
argument to the `_create_unique_sql` function, following their
implementation in the schema editor object. Without accepting this
keyword arg, migrations will crash like so:
```
...
File "lib/python3.8/site-packages/django/db/backends/base/schema.py", line 360, in add_constraint
sql = constraint.create_sql(model, self)
File "lib/python3.8/site-packages/django/db/models/constraints.py", line 118, in create_sql
return schema_editor._create_unique_sql(
TypeError: _create_unique_sql() got an unexpected keyword argument 'deferrable'
```
This also adjusts the implementation to call
`self_deferrable_constraint_sql(...)` with the deferrable arg; in this
backend's case the return value is an empty string (like it is currently
hardcoded). Essentially it's the same result but allows flexibility if
this backend ever supported deferrable constraints.
Backwards compatibility is maintained by checking for the passing of a
deferrable keyword argument to the create sql function (not provided on
earlier Django versions before 3.1) and that the database backend
supports deferral for unique indexes.
0 commit comments