John Siracusa <[EMAIL PROTECTED]> writes:

> Is NICADDRESS the primary key of whatever class/table the CMP_NETWORK
> relationship points to?

Hello John.

Thank you very much for your help. :)

No. The primary key is named NETWORKID.

I have found that the problem is using $row->...->load() and then $row->init()
using my hash. The values of the CMP_NETWORK related object are overridden then,
and the value of the primary key is missing afterwards. (Of all columns except
those set in the hash, to be exact.) So, RDBO makes an insert(), generating an
new primary key value, as you stated.

So, the problem I have is not using primary_key_generator, but finding a clever
way to store updated data. ;)

I have not found a smart way to update all related objects with ease yet.
I am using a foreach() construct now, but this only works with one sublevel.

    my $row     = $schema->new(
                      db   => $dbh,
                      %{ $idmap }
                      # contains KEYFIELD => value map
                  )->load(
                      with => $with
                      # list of related objects to load
                  );

    $row->init( %$data );
    # where data is _without_ related here
    
    foreach my $rel ( keys %{$related} ) {
        # hard coded here for testing only... I will have to add
        # another loop to iterate through the array
        my $manager = $row->CMP_NETWORK->[0]->class . '::Manager';
        # todo: check eval() return value 
        eval 'use '.$manager;
        my $func    = 'update_'.$rel;
        $manager->$func(
            set   => $related->{$rel},
            where => [ %{$idmap} ]
        );
    }

This works, but it's just "quick and dirty" for some testing. I seem to be at a
loss... So I'd really appreciate some further hints, though it's not really a
RDBO problem any longer. ;) I'm sure I just need a poke into some direction to
cut the knot. Thank you.

Bianka


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to