On Mon, Feb 25, 2008 at 09:19:49AM +0000, Chisel Wright wrote:
> On Mon, Feb 25, 2008 at 08:48:01AM +0000, Chisel Wright wrote:
> >   $coldata_hashref = $record->MAGIC_FUNCTION();
> 
> .. in the meantime, this appears to do what I need:
> 
>     map {
>         $data{$_} =
>             $result->get_column($_)
>     } $result->result_source->columns;

And you've just -used- the key part of your magic function!

$result->result_source($schema2->source(ref $result));
$result->in_storage(0);
$result->insert;

If you're sure that the record will either be identical in the other DB
or not present, $result->discard_changes will figure out if it's in the DB
or not. If you have changes as well, I guess

$result->result_source($schema2->source(ref $result));
my %save = $result->get_columns;
$result->discard_changes;
$result->set_column($_ => $save{$_}) for keys %save;
$result->insert_or_update;

would do the trick.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/

_______________________________________________
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/[EMAIL PROTECTED]

Reply via email to