Added some info about the nullable attribute #22

Merged
merged 1 commit into from Mar 13, 2013

Projects

None yet

2 participants

@wjzijderveld
Contributor

Via this PR: doctrine/phpcr-odm#260

@dbu dbu commented on the diff Mar 13, 2013
en/reference/annotations-reference.rst
@@ -148,6 +148,8 @@ Common optional attributes:
See :ref:`Mapping multivalue properties <basicmapping_mappingmultivalueproperties>`.
- **translated**: ``true`` to specify that the property should be translatable, requires the
``translator`` attribute to be specified in :ref:`@Document<annref_document>`.
+- **nullable**: ``true`` to specifiy that this property doesn't have a required value, used
+ when loading a translation, to allow loading a node with a missing translated property.
@dbu
dbu Mar 13, 2013 Member

what happens when we have a "nulled" property on a non-translated property? i think that should be handled by this as well, no?

@wjzijderveld
wjzijderveld Mar 13, 2013 Contributor

It wouldn't do anything, the only place it's used is when loading translations, it can only get there by looping over translated fields.

@dbu
dbu Mar 13, 2013 Member

indeed, here we check and just leave any property null if its not set in the database (btw, this is probably wrong in the case of refersh) https://github.com/doctrine/phpcr-odm/blob/master/lib/Doctrine/ODM/PHPCR/UnitOfWork.php#L301

@lsmith77 what do you think, should we check nullable here and if the field is nullable make sure it is null / empty array and otherwise throw an exception, like we do for translated fields?

@dbu dbu merged commit aa200fa into doctrine:master Mar 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment