use ing works just dandy, its when i relationship() the modules that it breaks : /

thanks for the help

the offending lines are commented out on the very last class. UserPropTypeBin

In order.... table definitions, classes, program using to test..

------------------------------------------------

CREATE TABLE `users` (
  `id` int(10) unsigned NOT NULL,
  `username` varchar(40) NOT NULL,
  `touch_d` datetime NOT NULL,
  `del_d` datetime NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `username` (`username`)
)

CREATE TABLE `user_prefs` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(40) NOT NULL,
  `nicename` varchar(80) NOT NULL,
  `description` text,
  `type_id` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `name` (`name`)
)

CREATE TABLE `user_pref_types` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(40) NOT NULL,
  `regex` varchar(255) default NULL,
  `table` varchar(255) NOT NULL,
  `usehash` tinyint(1) NOT NULL,
  PRIMARY KEY  (`id`)
)

CREATE TABLE `user_pref_type_bin` (
  `user_id` int(10) unsigned NOT NULL,
  `pref_id` int(10) unsigned NOT NULL,
  `p_value` blob,
  `vhash` char(32) NOT NULL,
  PRIMARY KEY  (`user_id`,`pref_id`,`vhash`)
)
-----------------------------------------------
package Cantella::PaperKiller::DB::User;

use strict;

#use Cantella::PaperKiller::DB::Doc;
#use Cantella::PaperKiller::DB::Group;
#use Cantella::PaperKiller::DB::File;
#use Cantella::PaperKiller::DB::Text;
#use Cantella::PaperKiller::DB::UserShare;
#use Cantella::PaperKiller::DB::UserFavorite;

use Cantella::PaperKiller::DB::UserPropTypeTime;
use Cantella::PaperKiller::DB::UserPropTypeInt;
use Cantella::PaperKiller::DB::UserPropTypeFloat;
use Cantella::PaperKiller::DB::UserPropTypeDate;
use Cantella::PaperKiller::DB::UserPropTypeChar;
use Cantella::PaperKiller::DB::UserPropTypeDatetime;
use Cantella::PaperKiller::DB::UserPropTypeBin;

use Cantella::PaperKiller::DB::UserPrefTypeTime;
use Cantella::PaperKiller::DB::UserPrefTypeInt;
use Cantella::PaperKiller::DB::UserPrefTypeFloat;
use Cantella::PaperKiller::DB::UserPrefTypeDate;
use Cantella::PaperKiller::DB::UserPrefTypeChar;
use Cantella::PaperKiller::DB::UserPrefTypeDatetime;
use Cantella::PaperKiller::DB::UserPrefTypeBin;

use Cantella::PaperKiller::DB::DB::Object::AutoBase1;
our @ISA = qw(Cantella::PaperKiller::DB::DB::Object::AutoBase1);

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

__PACKAGE__->meta->columns(
    id       => { type => 'integer', not_null => 1 },
    username => { type => 'varchar', default => '', length => 40, not_null => 1 },
    touch_d  => { type => 'datetime', default => '', not_null => 1 },
    del_d    => { type => 'datetime', default => '', not_null => 1 },
);

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

__PACKAGE__->meta->add_unique_keys([ 'username' ]);
__PACKAGE__->meta->relationships
    (
#     docs => 'one to many',
#     files => 'one to many',
#     texts => 'one to many',
#     user_shares => 'one to many',
#     user_favorites => 'one to many',
#     groups => 'many to many',



     ##PROPS
     _time_props => {type => 'one to many',
                     class => 'Cantella::PaperKiller::DB::UserPropTypeTime',
                     column_map => {id => 'user_id'}
                    },
     _datetime_props => {type => 'one to many',
                         class => 'Cantella::PaperKiller::DB::UserPropTypeDatetime',
                         column_map => {id => 'user_id'}
                        },
     _date_props => {type => 'one to many',
                     class => 'Cantella::PaperKiller::DB::UserPropTypeDate',
                     column_map => {id => 'user_id'}
                    },
     _char_props => {type => 'one to many',
                     class => 'Cantella::PaperKiller::DB::UserPropTypeChar',
                     column_map => {id => 'user_id'}
                    },
     _float_props => {type => 'one to many',
                     class => 'Cantella::PaperKiller::DB::UserPropTypeFloat',
                     column_map => {id => 'user_id'}
                    },
     _int_props => {type => 'one to many',
                    class => 'Cantella::PaperKiller::DB::UserPropTypeInt',
                    column_map => {id => 'user_id'}
                   },
     _bin_props => {type => 'one to many',
                    class => 'Cantella::PaperKiller::DB::UserPropTypeBin',
                    column_map => {id => 'user_id'}
                   },


     #PREFS
     _time_prefs => {type => 'one to many',
                     class => 'Cantella::PaperKiller::DB::UserPrefTypeTime',
                     column_map => {id => 'user_id'}
                    },
     _datetime_prefs => {type => 'one to many',
                         class => 'Cantella::PaperKiller::DB::UserPrefTypeDatetime',
                         column_map => {id => 'user_id'}
                        },
     _date_prefs => {type => 'one to many',
                     class => 'Cantella::PaperKiller::DB::UserPrefTypeDate',
                     column_map => {id => 'user_id'}
                    },
     _char_prefs => {type => 'one to many',
                     class => 'Cantella::PaperKiller::DB::UserPrefTypeChar',
                     column_map => {id => 'user_id'}
                    },
     _float_prefs => {type => 'one to many',
                      class => 'Cantella::PaperKiller::DB::UserPrefTypeFloat',
                      column_map => {id => 'user_id'}
                     },
     _int_prefs => {type => 'one to many',
                    class => 'Cantella::PaperKiller::DB::UserPrefTypeInt',
                    column_map => {id => 'user_id'}
                   },
     _bin_prefs => {type => 'one to many',
                    class => 'Cantella::PaperKiller::DB::UserPrefTypeBin',
                    column_map => {id => 'user_id'}
                   }

    );


__PACKAGE__->meta->initialize;

1;

----------------------------------------------------------------

package Cantella::PaperKiller::DB::UserPref;

use strict;
use Cantella::PaperKiller::DB::UserPrefType;

use Cantella::PaperKiller::DB::DB::Object::AutoBase1;
our @ISA = qw(Cantella::PaperKiller::DB::DB::Object::AutoBase1);

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

__PACKAGE__->meta->columns(
    id          => { type => 'integer', not_null => 1 },
    name        => { type => 'varchar', default => '', length => 40, not_null => 1 },
    nicename    => { type => 'varchar', default => '', length => 80, not_null => 1 },
    description => { type => 'text', length => 65535 },
    type_id      => { type => 'integer', default => '', not_null => 1 },
);

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

__PACKAGE__->meta->add_unique_keys([ 'name' ]);
__PACKAGE__->meta->relationships
    (
     type => {
              type => 'many to one',
              class=> 'Cantella::PaperKiller::DB::UserPrefType',
              column_map => { type_id => 'id'}
             }
    );


__PACKAGE__->meta->initialize;

1;

-------------------------------------------
File Edit Options Buffers Tools Perl Help                                                                                                                                                                       
package Cantella::PaperKiller::DB::UserPrefType;

use strict;

use Cantella::PaperKiller::DB::DB::Object::AutoBase1;
our @ISA = qw(Cantella::PaperKiller::DB::DB::Object::AutoBase1);

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

__PACKAGE__->meta->columns(
    id      => { type => 'integer', not_null => 1 },
    name    => { type => 'varchar', default => '', length => 40, not_null => 1 },
    regex   => { type => 'varchar', length => 255 },
    table   => { type => 'varchar', default => '', length => 255, not_null => 1 },
    usehash => { type => 'integer', default => '', not_null => 1 },
);

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

__PACKAGE__->meta->initialize;

1;

---------------------------------------------------------------
package Cantella::PaperKiller::DB::UserPrefTypeBin;

use strict;
use Cantella::PaperKiller::DB::User;
use Cantella::PaperKiller::DB::UserPref;

use Cantella::PaperKiller::DB::DB::Object::AutoBase1;
our @ISA = qw(Cantella::PaperKiller::DB::DB::Object::AutoBase1);

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

__PACKAGE__->meta->columns(
    user_id => { type => 'integer', not_null => 1 },
    pref_id => { type => 'integer', not_null => 1 },
    p_value => { type => 'blob', length => 65535 },
    vhash   => { type => 'character', length => 32, not_null => 1 },
);

__PACKAGE__->meta->primary_key_columns([ 'user_id', 'pref_id', 'vhash' ]);
__PACKAGE__->meta->relationships
    (
#    user => {  ### this is the offender. it makes it die
#             type => 'many to one',
#              class=> 'Cantella::PaperKiller::DB::User',
#              column_map => { user_id => 'id'}
#             },
     pref => {
              type => 'many to one',
              class=> 'Cantella::PaperKiller::DB::UserPref',
              column_map => { pref_id => 'id'}
             }
    );


__PACKAGE__->meta->initialize;

1;


#! /usr/bin/perl -w
use strict;
use warnings;
use diagnostics;
use Cantella::PaperKiller::DB::User;

use Rose::DB::Object;
use Data::Dumper;

my @info;
foreach my $class (Rose::DB::Object::Metadata->registered_classes){
    my $meta = $class->meta;
    my $tmp ={
              name    => $meta->table,
              primary => scalar $meta->primary_key_column_names,
              fields  => { map { $_->name => $_->type } $meta->columns },
              relations => {},
             };

    foreach my $r ($meta->relationships){
        while(my($l,$f) = each %{$r->{'_key_columns'}}){
            $tmp->{'relations'}{$l} = {t => eval($r->{class}."->meta->table"), f=>$f};
        }
    }
    push(@info,$tmp);
}

print Dumper([EMAIL PROTECTED]);


On 5/1/06, John Siracusa <[EMAIL PROTECTED]> wrote:
On 5/1/06 7:09 PM, Guillermo Roditi wrote:
> Is it because there is a circular relationship??? where every user has many
> props and many props have one user?  it seems what heppens is that its
> trying to make a user object  and so it makes the prop type object and then
> it tries to make a user object for the proptype, except it can't because
> that's what its doing already

Circular relationships should work, but may depend on the order and way (use
vs. require) the modules include each other.  Can you post the two table
definitions and your associated Perl classes?

As for a debug mode, for class init you can try setting
$Rose::DB::Object::Metadata::Debug = 1.  It will print a bunch of stuff
which may or may not be helpful :)

-John




-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to