[RDBO] Deleting 'one to one' object fails

2007-06-11 Thread Ovid
In my meta setup for one object, I have the following:

relationships = [
suspended = {
class  = 'Donhost::Server::Dedicated::Suspended',
column_map = { server = 'server' },
type   = 'one to one',
required   = 0,
},
],

And when I try to delete the corresponding object in there:

  $self-delete_suspended;

  diag Dumper($self-suspended);

I still have a Donhost::Server::Dedicated::Suspended object in there.

I thought, maybe I need to save it first:

  $self-delete_suspended;
  $self-save;
  diag Dumper($self-suspended);


Nope:

  not ok 5 - cannot_reinitialize died (No foreign key named 'suspended' at 
/usr/local/lib/perl5/site_perl/5.8.7/Rose/DB/Object.pm line 539 ...
  #   eval {...} called at 
/usr/local/lib/perl5/site_perl/5.8.7/Rose/DB/Object.pm line 478
  #   Rose::DB::Object::save() called at lib/Donhost/Server/Dedicated.pm 
line 563

As you can see, the error is thrown when I call 'save'.  However, it complains 
about a missing foreign key, even though I thought relationships are supposed 
to be used when we don't have foreign keys.  I've tried reading through the 
docs and the tests on this, but no luck.

This is Rose::DB::Object 0.764.

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


Re: [RDBO] Deleting 'one to one' object fails

2007-06-11 Thread John Siracusa
On 6/11/07 8:46 AM, Ovid wrote:
 And when I try to delete the corresponding object in there:
 
   $self-delete_suspended;
 
   diag Dumper($self-suspended);
 
 I still have a Donhost::Server::Dedicated::Suspended object in there.
 
 I thought, maybe I need to save it first:

You do, because the delete method created (by default) for a one-to-one
relationship is a delete_on_save method.

   $self-delete_suspended;
   $self-save;
   diag Dumper($self-suspended);
 
 
 Nope:
 
   not ok 5 - cannot_reinitialize died (No foreign key named 'suspended' at
 /usr/local/lib/perl5/site_perl/5.8.7/Rose/DB/Object.pm line 539 ...
   #   eval {...} called at
 /usr/local/lib/perl5/site_perl/5.8.7/Rose/DB/Object.pm line 478
   #   Rose::DB::Object::save() called at lib/Donhost/Server/Dedicated.pm
 line 563

Is cannot_reinitialize one of your methods?  If so, what does it look
like?

-John



-
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


Re: [RDBO] Deleting 'one to one' object fails

2007-06-11 Thread Ovid
- Original Message 
From: John Siracusa [EMAIL PROTECTED]

  $self-delete_suspended;
  $self-save;
  diag Dumper($self-suspended);
 
  Nope:
 
   not ok 5 - cannot_reinitialize died (No foreign key named 'suspended' at
  /usr/local/lib/perl5/site_perl/5.8.7/Rose/DB/Object.pm line 539 ...
   #   eval {...} called at
  /usr/local/lib/perl5/site_perl/5.8.7/Rose/DB/Object.pm line 478
   #   Rose::DB::Object::save() called at lib/Donhost/Server/Dedicated.pm
  line 563

 Is cannot_reinitialize one of your methods?  If so, what does it look
 like?

Er, um, it's an embarrassing holdover from an earlier refactoring.

  sub cannot_reinitialize {
  my $self = shift;
  
  if ( $self-suspended ) {
  return 'Suspended';
  }
  elsif ( $self-state eq none qw/ allocated install_failed / ) {
  return 'Not allocated';
  }
  elsif ( !$self-has_standard_hardware ) {
  return 'Running on non-standard hardware';
  }
  return;
  }

And before you ask :)

  sub has_standard_hardware {
  defined shift-_hardware_spec_id;
  }

('_hardware_spec_id' merely refers to a varchar(32) column.  Nothing unusual 
about it)

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


Re: [RDBO] Deleting 'one to one' object fails

2007-06-11 Thread John Siracusa
On 6/11/07 8:46 AM, Ovid wrote:
 In my meta setup for one object, I have the following:
 
 relationships = [
 suspended = {
 class  = 'Donhost::Server::Dedicated::Suspended',
 column_map = { server = 'server' },
 type   = 'one to one',
 required   = 0,
 },
 ],

I can't reproduce this error with similarly (as far as I can tell)
structured relationships.  Can you send me a self-contained example with
table and class definitions that reproduces the problem (by private email if
you want).

-John



-
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


Re: [RDBO] Deleting 'one to one' object fails

2007-06-11 Thread Ovid
- Original Message 
From: John Siracusa [EMAIL PROTECTED]

 I can't reproduce this error with similarly (as far as I can tell)
 structured relationships.  Can you send me a self-contained example with
 table and class definitions that reproduces the problem (by private email if
 you want).

I'll see if I can get that to you tomorrow.  Thanks.

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


Re: [RDBO] augmenting ManyToMany default_auto_method_types

2007-06-11 Thread Michael Reece

On Jun 11, 2007, at 9:22 AM, John Siracusa wrote:

 On 6/11/07 12:14 PM, Michael Reece wrote:
  method_types = [
  Rose::DB::Object::Metadata::Relationship::ManyToMany-
 default_auto_method_types(),
  'count'
 ],
  },

 Try:

 add_methods = [ 'count' ],

fantastic, thanks.

i am in the process of porting some code from CDBI::Sweet to RDBO,  
and one thing that tripped me up trying to use an offset + rows, when  
rows s.b. 'limit' for RDBO..

i was getting an error like Could not find MyDB::Message objects -   
at ...

after a little digging:

in Rose::DB::Object::Manager, sub get_objects, ~ line 1608:

 if(defined $args{'offset'})
 {
   Carp::croak Offset argument is invalid without a limit argument
 unless($args{'limit'} || $manual_limit);


in Rose::DB::Object::MakeMethods::Generic, sub objects_by_map, ~ line  
4314:

 if($@ || !$objs)
 {
   $self-error(Could not find $foreign_class objects -  .  
$map_manager-error);
   $self-meta-handle_error($self);
   return wantarray ? () : $objs;
 }

however, the error is in $@ and not $map_manager-error, so the  
reason for the failure is not reported.





-
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


Re: [RDBO] augmenting ManyToMany default_auto_method_types

2007-06-11 Thread John Siracusa
On 6/11/07 1:21 PM, Michael Reece wrote:
 however, the error is in $@ and not $map_manager-error, so the
 reason for the failure is not reported.

Thanks, I correct the error propagation when I get a chance.

-John



-
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


[RDBO] Postgresql default value for timestamp causes RDBO failure

2007-06-11 Thread Fred Cox
insert() - Invalid default timestamp: '(now() + '21
days'::interval)' at
/usr/local/lib/perl5/site_perl/5.8.8/Rose/DB/Object.pm
line 1106

The column definition looks like this:
tsexpire   | timestamp without time zone | not
null default (now() + '21 days'::interval)

Should I expect valid default values to work?  Or is
there a way I can get RDBO to allow Postgresql to come
up with the default value?

Thanks,

Fred


   

Be a better Heartthrob. Get better relationship answers from someone who knows. 
Yahoo! Answers - Check it out. 
http://answers.yahoo.com/dir/?link=listsid=396545433

-
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