[Dbix-class] RFC: DBIx::Class::Sweet

Matt S Trout dbix-class at trout.me.uk
Mon Apr 3 20:44:09 CEST 2006


Nilson Santos Figueiredo Junior wrote:
> On 4/3/06, Matt S Trout <dbix-class at trout.me.uk> wrote:
>> Depends. For rapid prototyping it's extremely handy to be able to just dump it
>> all into one file and then move things out later.
> 
> Yes. But after this rapid prototyping stage, I'd rather have it at each class.

Hence "support both" :)

>> The big problem is that if you're going to be importing methods in order to
>> make things a bit cleaner you have to be able to un-import them to avoid
>> leaving the class namespace full of crap (or take the package
>> My::Table::Schema sets up My::Table approach that Jifty::DBI does) - and the
>> best hook for un-importing I can find is "when the block's been executed",
>> unless you want to either expect the user to call 'declaration_done;' when
>> they're finished or do something heinous involving source filters ...
> 
> I don't think this is that big of a deal, since the methods were
> already "virtually" there through inheritance. But, as I said, the
> code block wrapper is also reasonable.

yeah, but then if they're called as a method you have to try and DWIM and it 
all gets icky. removing anything you imported for setup purposes is essential 
- it also means you can use more concise names for setup stuff without 
worrying about namespace clashes.

>> Yeah, my point is that (1) the columns need to be auto-created, (2) we have to
>> deal with multi-col PKs transparently as well if possible.
> 
> Couldn't the columns be auto-created if they did not already exist?
> If you had multi-column PKs then you'd need to specify them manually. E.g.
> 
>   has_many 'clients', -keys => [qw(client_id client_name)];

I don't see why I need to do that. If the f_class' PK is (id_one, id_two) I'm 
happy for belongs_to 'foo' => 'Foo' to create foo_id_one and foo_id_two columns.

I also want to have the 'reverse' attr on a belongs_to rather than explicit 
has_many calls - saves us having circular loading failure issues and means 
that the parent class can be re-used *without* the child class if suitable.

-- 
      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