[Dbix-class] create() with has_one related object broken

Hermida, Leandro Leandro.Hermida at fmi.ch
Mon Jun 8 21:12:01 GMT 2009


On Thu, Jun 04, 2009 at 03:38:21PM +0200, Hermida, Leandro wrote:
>> If I try like the documentation says to do in create() with a
has_one
>> relationship, with an arrayref of hashrefs:


> arrayref is for has_many.
> 
> For might_have/belongs_to/has_one there's only one so you just pass a
> hashref.
> 
> If the docs don't make this clear, please supply a patch :)

Hi,

My apologies, there must be an error in the docs
http://search.cpan.org/~ribasushi/DBIx-Class-0.08103/lib/DBIx/Class/Resu
ltSet.pm#create.  It clearly states, "For has_many and has_one
relationships, pass an arrayref of hashrefs containing the data for each
of the rows to create in the foreign tables, again using the
relationship name as the key." and then further down, "Example of
creating a new row and also creating rows in a related has_many or
has_one resultset. Note Arrayref."

Also, I tried just one hashref as it made more sense and it still
doesn't work, please see second error I got in original email.

Leandro 




More information about the DBIx-Class mailing list