I've created a custom Metadata class to use with RDBO::Loader so I can have
an init_column_name_to_method_name_mapper method to change CamelCase
to underscore_separated and strip table names from the front of column
names.

This worked well but now my method names are not the same as my column
names so I think that I need to include some POD in the generated
classes.

The module_postamble option to RDBO::Loader comes in handy. I pass it a
sub that looks like this:

 sub make_pod {
   my $meta = shift;
   my $pod;
   my $tt = Template->new();
   $tt->process('pod.tt', {meta => $meta, db => $db}, \$pod)
      or die  $tt->error;
   return $pod;
 }

Now I'm cooking! I have access to the Metadata object for each class
and my Rose::DB object in a Template Toolkit template.

I can get all of the data I need for the primary keys:

 =head1 Primary Keys

 [% IF meta.primary_key_column_names.list.size > 1  %]
 This table has a composite primary key consisting of:
 [% END %]
 =over 4
 [% FOREACH pk IN meta.primary_key_columns %]
 =item B<[% pk.name %]> ( [% meta.table %].[% pk.column %] )
 [% END %]
 =back

This also works well for the columns but it starts to fall
down when I hit foreign keys and relationships.

Information about the table that they point to doesn't
appear to be readily available. I have read the documentation for
RDBO::Metadata, RDBO::Metadata::ForeignKey,
RDBO::Metadata::Relationship, RDBO::Metadata::Relationship::OneToOne,
RDBO::Metadata::Relationship::OneToMany.

I can get the columns from both tables but not the table name.
Previously when generating forms from table definitions I've gotten
around this by actually loading the FK class. I can't in this case
because the class hasn't been generated yet.

What docs did I miss and what approach should I take here?

Thanks,
Clayton

-- 

Clayton Scott
[EMAIL PROTECTED]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to