On 7/28/06 9:02 AM, Ritesh Errno wrote:
> I am following the canoical method of auto init like this -
> 
>  __PACKAGE__->meta->table("footable");
> __PACKAGE__->meta->auto_initialize;
> 
> But it does not pick up the foreign keys, since the table -> class mapping
> does not follow the convention.
> 
> I tried adding:
> __PACKAGE__->meta->foreign_key( ffkey => [ .......] )
> 
> or
> __PACKAGE->meta->add_foreign_key
> 
> resulting in various complaints in redefining methods or unknown methods.

Are you trying to add the foreign key before or after you call
auto_initialize()?  If you call it before, it should work without warnings
since auto_initialize() should skip over any foreign key that already exists
and has the same column mappings as a foreign key it's trying to
auto-create.  Can you post your table definitions?

> If you can suggest a way to do that it would really make my mapping modules
> auto-magical since I really would like to use auto_initialize.

Making a custom ConventionManager that is in sync with whatever naming
conventions you're using is the cleanest way to make auto-init "just work"
for your database, but it may be more work than manually tweaking your
classes with explicit calls to add_foreign_key() or whatever.  It depends on
how many classes you have to auto-init.

-John



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to