doctrine/phpcr-odm — pull request #314 by dbu (2013-08-05 21:39:20+00:00)
Title: check nullable fields and throw an exception when trying to set to null

| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | yes
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #308
| License | MIT
| Doc PR | -

Theoretically, this is just a bugfix, but one with potentially a big impact on sloppy clients that relied on this bug. Until now, nothing ever checked if a non-nullable field was null. With the recent translation fixes, this could lead to the situation where we save a translation with missing non-nullable fields and then can not load it anymore.

This PR changes the UoW to check if all non-nullable fields are indeed non-null (unless they are jcr:uuid or autocreated, that is). As you can see from the fixes to the tests, this can have quite an impact.

Imo we need this validation. The ORM delegates this to the SQL database. We do not generate PHPCR node types for our documents which could make PHPCR do that validation for us. For general reliability and forward compatibility with eventual node type generation, we need to validate.

I wonder if we should also validate on loading documents - but i guess it is the job of the user to make sure his updates also include the necessary PHPCR updates.