Skip to content

0.6 breaks default blank value #11

@jonashaag

Description

@jonashaag

EDIT: This just happened in production as well, so it's not a model-mommy/test problem. Production: None is the default database value of a separated values field, when it should be ''.

With Django < 2 and model-mommy, default value for the separated values field is incorrectly None (rather than ''). Now model-mommy doesn't actually support separated values field, but if it has blank=True it used to work anyways. I tried to pinpoint the exact reason but I'm not sure where it is.

To reproduce:

from django.db import models
from separatedvaluesfield.models import SeparatedValuesField

class TestModel(models.Model):
    f = SeparatedValuesField(max_length=255, blank=True)
model_mommy.mommy.make('testapp.TestModel')

With 0.5 this resulted in the following insert query:

INSERT INTO "testapp_testmodel" ("f") VALUES (?) ['']

With 0.6 this results in the following insert query:

INSERT INTO "testapp_testmodel" ("f") VALUES (?) [None]

The None value violates the separated value field's NOT NULL constraint, making the insertion fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions