I am doing a BAD THING and cross-posting to this list and Catalyst, but it
isn't exactly a catalyst issue, either.  Feel free to ignore if too far
astray.

I have the following classes and ApacheAdmin::Model::DB is just for
connecting to the database--nothing unusual there.  With the test script at
the bottom, I get the following error:

Cannot load ApacheAdmin::Model::User without a primary key (username) with a
non-null value or another unique key with at least one non-null value. at
test.pl line 9

If I remove the inheritance from Catalyst::Model, everything works fine.
It's not too big a deal in practice--I don't NEED the catalyst::model
inheritance--but I'm curious why this doesn't work.

Thanks,
Sean


package ApacheAdmin::Model::User;

use strict;

use ApacheAdmin::Model::Base;
our @ISA = qw(ApacheAdmin::Model::Base);

__PACKAGE__->meta->table('users');

__PACKAGE__->meta->columns(
    username  => { type => 'varchar', not_null => 1 },
    pass      => { type => 'varchar' },
    groupname => { type => 'varchar', length => 50 },
);

__PACKAGE__->meta->primary_key_columns([ 'username' ]);

__PACKAGE__->meta->relationships(
    groups => {
        column_map    => { username => 'username' },
        foreign_class => 'ApacheAdmin::Model::Group',
        map_class     => 'ApacheAdmin::Model::UserGroupMap',
        map_from      => 'user',
        map_to        => 'group',
        type          => 'many to many',
    },
);

__PACKAGE__->meta->initialize;

1;


package ApacheAdmin::Model::Base;
use strict;

use ApacheAdmin::Model::DB;

use Rose::DB::Object;
use Catalyst::Model;
our @ISA = qw(Catalyst::Model Rose::DB::Object);

sub init_db { my $db = ApacheAdmin::Model::DB->new();
              $db->connect_option(AutoCommit => 0);
              $db->connect_option(RaiseError => 1);
              return $db; }

1;



#!/usr/bin/perl
use strict;
use lib '../lib';

use ApacheAdmin::Model::User;

my $user = ApacheAdmin::Model::User->new(username => 'doron');

$user->load();

print "";

    




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to