[Dbix-class] column accessor namespace

Matt S Trout dbix-class at trout.me.uk
Tue Jul 4 19:46:57 CEST 2006


Dave Howorth wrote:
> Matt S Trout wrote:
>> You might like to have a play with Schema::Loader's dump_to_dir method, which 
>> would allow you to generate the DBIC definitions for stuff, and then tweak 
>> appropriately (changing __PACKAGE__->belongs_to into an explicit 
>> add_relationship call should get rid of that clash)
> 
> I managed to get it to produce some definition classes by 'exclude'ing 
> one class at a time. First the class that has the belongs_to and then 
> the class that it refers to. Excluding either was enough to get it to 
> generate (an approximation to) a class for the other.
> 
>> DBIC tends to overwrite methods rather than barfing like CDBI does since often 
>> you *can* overwrite a substantial number of provided methods without it 
>> failing. You could even, provided your "belongs_to" column doesn't need to be 
>> a belongs_to rel itself, simply add_columns it as the last thing in the file :)
> 
> Yeah, it did that OK as above. Sadly, in real life it will need to be a 
> relationship, but that's a problem for another day. Today, I don't need 
> to access those tables :)

That's still do-able - remember, has_many, might_have, has_one and belongs_to 
are all *just* convenience methods that fill out some "sane defaults" for that 
type of relationship and then call add_relationship.

You don't have a column called add_relationship, right? *crosses fingers*

(and you can pass { accessor => 'name' } to add_columns to rename the accessor 
anyway, although this *only* renames the accessor - the feature's a bit rough 
round the edges but I don't need it and nobody's given me test cases so far 
for the bits that need fixing ;)

> Once again, thanks to all involved for a great set of modules.

Cheers. @dbic-devel, give yourselves a hug from me, we're doing ok :D

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list