- changed milestone to 0.7.xx
Cannot insert a base class when using single table inheritance.
Issue #2068
resolved
The attached example raises: sqlalchemy.exc.IntegrityError: (IntegrityError) tests.type may not be NULL u'INSERT INTO tests (type) VALUES (?)' (None,)
We’d expect it to insert a Test2 instance into the DB I think. I am not sure this is a bug. However, if it is not, the error message should be more explicit. Something like «Cannot insert an abstract class into the DB»...
Comments (4)
-
repo owner -
Account Deleted test = Test2() db_session.add(test) db_session.commit() test = Test2() db_session.add(test) db_session.commit() test = Test3() db_session.add(test) db_session.commit() test = Test(type='type1') db_session.add(test) db_session.commit() test = Test(type='type2') db_session.add(test) db_session.commit() result = db_session.query(Test).all() for row in result: print row.id, row.type
Now results in:
1 type1 2 type1 3 type2 4 type1 5 type2
Ah... now I see, you said this was already fixed by
#1895...I'm not the guest that entered this ticket BTW -- they can still answer the use case question.
-
repo owner - changed status to wontfix
this is tested by test/orm/inheritance/test_basic.py->PolymorphicAttributeManagementTest.test_assignment and is expected behavior in 0.7.
-
repo owner - changed milestone to 1.x.xx
- Log in to comment
this behavior was fixed by
#1895.Still wondering if that activity should emit a warning, though. Depends on what the use case for Test(type='test1') really is (so what is it ?)