[Dbix-class] Update

Alexander Hartmaier alexander.hartmaier at t-systems.at
Mon Aug 8 10:24:25 GMT 2011


DBIx::Class::ResultSet::RecursiveUpdate can do that.
We'd love to see the functionality in core but noone has stepped up to
write tests against the dbic test schema so someone can implement it in
core.

Cheers, Alex

Am 2011-08-05 19:03, schrieb Martin Bendix:
> Hi,
>
> Using "create" in DBIx::Class::ResultSet, I can specify a hashref of
> related-object column values, and that will cause the appropriate foreign key
> for the `belongs_to` relationship to be looked-up and included in the row:
>
> $row = $event_rs->create({
>      event =>  "My event",
>      recur =>  { freq =>  "daily" },
> });
>
> Is it possible to perform a similar action when updating the row?  For example,
> something like this:
>
> $row->update({
>      event =>  "My updated event",
>      recur =>  { freq =>  "weekly" },
> });
>
> The above fails because the update method is expecting a row object for the
> relation, not a hashref.  At the moment, I am performing a separate "find" to
> locate the matching "recur" row, then using that in the "update" method:
>
> $recur = $recurrence_rs->find({ freq =>  "weekly" });
>
> $row->update({
>      event =>  "My updated event",
>      recur =>  $recur,
> });
>
>
>
>
> Many thanks,
>
> Martin
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*



More information about the DBIx-Class mailing list