I have a 'server' object.  There's a 'suspension' table which has an
optional single record for each server.  If a server is suspended, the
table gets a record of metadata for why the server was suspended.  When
the server is unsuspended, we delete said record.  In my server class,
I have this:

    relationships => [
        suspended => {
            class      => 'My::Server::Dedicated::Suspended',
            column_map => { server => 'server' },
            type       => 'one to one', # should be one to optional one
        },
    ],

('server' is merely an integer id and it happens to be the primary key
of the 'servers' table)

When I try to 'unsuspend' a server by deleting the suspension record, I
I get strange errors.  My latest attempt to do this is with:

  $suspension->delete;
 
However, my $server object still has a record of that suspension, so
$server->suspended still returns true.  So I follow that up with:

  $server->suspended(undef);

And that deletes my $server's id!  I then get strange errors like this:

DBD::mysql::st execute failed: called with 27 bind variables when 28
are needed at /usr/local/lib/perl5/site_perl/5.8.7/Rose/DB/Object.pm
line 843.

In that, the @keys_values array is empty (that should be the ID).  The
ID gets eliminated via this:

    diag "Server ID is $server at line ".__LINE__;   # 309
    $suspended->delete;
    diag "Server ID is $server at line ".__LINE__;   # 311
    $server->suspended(undef);                       # boom!
    diag "Server ID is $server at line ".__LINE__;   # 313
    $server->save;

Which outputs:

    # Server ID is 1 at line 309
    # Server ID is 1 at line 311
    # Server ID is  at line 313

So I am assuming that I'm using 'relationships' wrong.  I've tried
adding 'required => 0' and 'optional => 1' to my definition, but that
seems to have no affect.  How can I have my server delete the suspended
record without the server ID going away?

Cheers,
Ovid

--

Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to