smallvaluesof2 has asked for the wisdom of the Perl Monks concerning the following question:
I am using DBIx and am having some issues reading an object from DB that has a belongs_to relationship defined on an optional field. If the optional field is NULL in the DB, the accessor for reading the field attempts to create a new entry in the foreign table with blank/null values instead of (as I would like it) just returning undef.
Apart from not wanting blank values in the foreign table, the subsequent insert-by-side-effect calls will fail as a uniqueness constraint will be violated.
A sample scenario is a car table with an optional radio_type column which is either NULL or holds the foreign key of a radio_type table row.
I'm not sure if I am grappling with default well intentioned behaviour that can be disabled or have just made some basic error. Enlightenment appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBIx, using belongs_to on optional field, insert-by-side-effect in foreign table
by kennethk (Abbot) on Jan 19, 2009 at 15:12 UTC | |
by smallvaluesof2 (Novice) on Jan 19, 2009 at 16:06 UTC |