If I create a new Rose::DB::Object without specifying some not-null  
fields, should the getters return a defined or undefined value?

The following script provides different answers for sqlite and mysql.
swartz> ./rose.pl sqlite
email is not defined
swartz> ./rose.pl mysql
email is defined

and I believe the mysql behavior is leading to a bug dealing with  
multiple unique keys.

rose.pl:
#!/usr/bin/perl
use DBI;
use Data::Dump qw(dump);
use File::Temp;
use warnings;
use strict;

package Tmp::DB;
use base qw(Rose::DB);
__PACKAGE__->use_private_registry;
my $tmpfile;
if ($ARGV[0] eq 'sqlite') {
     $tmpfile = File::Temp->new();
     __PACKAGE__->register_db(driver => 'sqlite', database =>  
$tmpfile->filename);
}
else {
     __PACKAGE__->register_db(driver => 'mysql', host =>  
'localhost', ...);
}

my @sql =
     ('DROP TABLE IF EXISTS accounts',
      'CREATE TABLE accounts (
        id int(10) primary key,
        email varchar(100) not null
        )',
     );
my $dbh = Tmp::DB->new->retain_dbh;
$dbh->do($_) foreach @sql;

package Tmp::Account;
use base qw(Rose::DB::Object);
sub init_db { Tmp::DB->new }
__PACKAGE__->meta->auto_initialize;

package main;
my $user;
$user = Tmp::Account->new(id => 1);
print "email is " . (defined($user->email()) ? "defined" : "not  
defined") . "\n";


-------------------------------------------------------------------------
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