CodeIgniter Forums
Datamapper ORM, from_array with optional hasOne associations - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Datamapper ORM, from_array with optional hasOne associations (/showthread.php?tid=58663)



Datamapper ORM, from_array with optional hasOne associations - El Forum - 07-04-2013

[eluser]Unknown[/eluser]
I'm reporting a problem with the from_array code of when a hasOne is optional. When a value is not set in the data, the code attempts to delete an old value for the association. However, if the value of the association was not previously set, a database error is throw about being unable to related models. The delete operation on line 165 needs to be protected by exists test on the old value.


Datamapper ORM, from_array with optional hasOne associations - El Forum - 07-04-2013

[eluser]WanWizard[/eluser]
Can you code up a fix? I don't have time to look into it at the moment.