mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-525: STI Fields null vs not null behaviour #654
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Apr 16, 2010).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user @beberlei:
What is the expected behaviour for fields on STI sub-classes?
A user reported on IRC that he had issues with Sqlite inserting null values (failing) vs Mysql which inserted empty strings.
@doctrinebot commented on GitHub (Apr 16, 2010):
Comment created by @beberlei:
beberlei; final note before i move to other issues: I found that MySQL puts empty strings in columns that are not specified in the column list of the query, vs sqlite that puts nulls into non-specified columns. That explains a lot of it..
@doctrinebot commented on GitHub (Apr 16, 2010):
Comment created by mluiten:
Said user reporting in :-)
Found this extremely annoying mostly due to inconsistent behavior between different drivers. I just found that MySQL inserts empty strings ('') into columns not specified in the INSERT query, while SQLite inserts NULLs. I'd say SQLite is technically correct..
E.g. a superclass Collector (id, name) which has a subclass SpecialCollector, with the column 'subdomain' added (nullable=false).
When creating a subclass without the subdomain field, Doctrine creates an insert query without subdomain and thus works fine. SQLite however, gives an error.
Possible solutions would be to include every column of subclasses to the query and hard-set to empty string, or to imply NOT NULL on all columns of subclasses during table creation, and check for NULL in the DBAL instead. But I'll let the big boys figure that out ;-)
@doctrinebot commented on GitHub (Apr 16, 2010):
Comment created by romanb:
Columns mapped by child classes in single table inheritance must be nullable.
The behavior of mysql looks weird to me, too.
@doctrinebot commented on GitHub (Apr 26, 2010):
Comment created by romanb:
So do we have an issue here, assuming columns mapped by child classes in STI must be nullable? If yes what is the problem?
@doctrinebot commented on GitHub (Sep 27, 2010):
Comment created by @beberlei:
The problem is that currently you had to do nullable=true on all the fields in chield entities of STI.
Now SchemaTool doe this automatically.
@doctrinebot commented on GitHub (Sep 27, 2010):
Issue was closed with resolution "Fixed"