-
-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
Two kinds of problems here (the cause is probably the same):
class A(models.Model):
id = models.CharField(max_length=50, primary_key=True)
class B(A):
pass
Expected :id for b
Actual :DFKYQIC7NU2NOPVAL2CV5I4JZJPIHA5BP9BHGOWFEX4X825Q5T
@pytest.mark.django_db
def test_setting_id():
from smartpatient.events.models import A, B
a = N(A, id='id for a')
assert a.id == 'id for a'
b = N(B, id='id for b')
> assert b.id == 'id for b'
E AssertionError: assert 'DFKYQIC7NU2NOPVAL2CV5I4JZJPIHA5BP9BHGOWFEX4X825Q5T' == 'id for b'
G has the same problem.
If I leave the A.id field default, then:
class A(models.Model):
pass
class B(A):
pass
@pytest.mark.django_db
def test_setting_id():
from smartpatient.events.models import A, B
a = N(A, id=555)
assert a.id == 555
> b = N(B, id=666)
(...)
self = <_mysql.connection open to 'mysql-all' at 0x3b65bb8>
query = b'INSERT INTO `events_a` (`id`) VALUES (DEFAULT)'
def query(self, query):
# Since _mysql releases GIL while querying, we need immutable buffer.
if isinstance(query, bytearray):
query = bytes(query)
> _mysql.connection.query(self, query)
E django_dynamic_fixture.ddf.BadDataError: ('events.models.A', IntegrityError(1364, "Field 'id' doesn't have a default value"))
../.virtualenvs/venv3.6/lib/python3.6/site-packages/MySQLdb/connections.py:224: BadDataError
Python 3.6
Django 2.0.13
DDF 2.0.0 (the same problems with 3.1.1)
It worked before the upgrade from Django 1.11.29 and DDF 1.9.5. I suspect the changes in Django broke this functionality in DDF.
Thanks in advance for fixing this! DDF is very, very useful and convenient for testing, generating sample data, and whatnot. Big kudos to all contributors!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels