Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.6 breaks default blank value #11

Open
jonashaag opened this issue Aug 22, 2018 · 0 comments
Open

0.6 breaks default blank value #11

jonashaag opened this issue Aug 22, 2018 · 0 comments

Comments

@jonashaag
Copy link

jonashaag commented Aug 22, 2018

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.

@jonashaag jonashaag changed the title 0.6 breaks model-mommy compatibiltiy 0.6 breaks default blank value Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant