• 
      

    Don't try to apply defaults to certain database-specific field types.

    Review Request #12283 — Created May 16, 2022 and submitted

    Information

    Django Evolution
    release-2.x

    Reviewers

    On MySQL, text, blob, json, and the short/medium/long
    varieties of the first two are forbidden from having default values.

    Django Evolution would try to apply these anyway when adding a non-NULL
    field or changing a field to be non-NULL (and in fact validated that
    such a value would be provided when setting to non-NULL). This would
    prevent these types of fields from being added unless they were set to
    allow NULL.

    Now, the evolution op backends can override a
    get_field_type_allows_default() method, which can check a field to
    determine if default values should be allowed. This is used when
    building a column schema definition, ensuring that any DEFAULT-related
    SQL is omitted if not allowed for the field.

    Unit tests pass for all supported database types on all supported
    versions of Django.

    Summary ID
    Don't try to apply defaults to certain database-specific field types.
    On MySQL, `text`, `blob`, `json`, and the `short`/`medium`/`long` varieties of the first two are forbidden from having default values. Django Evolution would try to apply these anyway when adding a non-NULL field or changing a field to be non-NULL (and in fact validated that such a value would be provided when setting to non-NULL). This would prevent these types of fields from being added unless they were set to allow NULL. Now, the evolution op backends can override a `get_field_type_allows_default()` method, which can check a field to determine if default values should be allowed. This is used when building a column schema definition, ensuring that any `DEFAULT`-related SQL is omitted if not allowed for the field.
    bc10ee5cd1e1e7f37386944cc075be832b79e397
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-2.x (35befe7)