On 10/18/05 11:14 PM, Terrence Brannon wrote:
> On 10/18/05, John Siracusa <[EMAIL PROTECTED]> wrote:
>> (Replace the all the calls to meta->initialize() with
>> calls to auto_initialize(no_warnings => 1) and the column details would be
>> filled in automatically as well.)
> 
> I think the auto_initialize usage would look more spiffy in the SYNOPSIS of
> your docs. When you say column details, do you mean just the column names or
> also that some of the columns are foreign keys?

I mean this:

    __PACKAGE__->meta->columns(qw(id name age));

vs. this:

    __PACKAGE__->meta->columns
    (
      id    => { type => 'int', primary_key => 1, not_null => 1 },
      name  => { type => 'varchar', length => 255 },
      age   => { type => 'int' },
    );

I used the former in my examples, but the later is what auto_initialize()
would create (or what I'd create manually if I wrote it out longhand).

As for auto-initializing foreign keys, that only works on databases with
real foreign key support.  The fk name is taken from the db as well (usually
the constraint name) so it requires some forethought in the schema design if
you want to auto-init foreign keys and get the accessor method names you
want.

Anyway, unfortunately, there's a bit of an chicken/egg situation with
many-to-many relationships when using BOTH auto_initialize() and the
convention manager to their maximum extents.  So while you can reduce, say,
the vendor class to this:

    package My::Vendor;
    use base 'My::Object';
    __PACKAGE__->meta->auto_initialize;

and it works fine, once you start stripping down the classes that
participate in the product/colors many-to-many relationship in a similar
manner, you eventually run out of DWIMery :)

-John




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to