[Catalyst] CDBI vs DBIx

Matt S Trout dbix-class at trout.me.uk
Fri Mar 17 14:04:04 CET 2006


Nilson Santos Figueiredo Junior wrote:
> On 3/16/06, A. Pagaltzis <pagaltzis at gmx.de> wrote:
>> Well, those are exactly what better ORMs make easier to do.
>> Without joins, a database is little more than a more structured
>> flatfile.
> 
> But you can get joins with Class::DBI::Sweet.

Implict joins, yes. Explicit JOINs, LEFT JOINs etc., no. and in Sweet it's a 
massive kludge I had to fight CDBI every step of the way to implement, whereas 
DBIC had it build in from the ground up.

> Anyway, I'm not exactly aware of what are all the benefits of
> switching to DBIx::Class. I did it mainly for two reasons: it's
> somehow faster than Class::DBI::Sweet and it is the preferred Catalyst
> ORM.

I could explain how, but it'd involve a tour of the CDBI internals your sanity 
might never recover from (mine still hasn't). Over a pint one day, maybe :)

> But I'd also be glad if all DBIx::Class advantages against
> Class::DBI::Sweet were enumerated, just for the sake of knowing it.

- actually designed to be an ORM (rather than CDBI, which is a "Simple 
Database Abstraction" and does exactly what it says on the tin)

- understands multi-col PKs, LEFT JOINs etc. and supports prefetch to retrieve 
as much as possible in a single query (including some support for doing so for 
has_many relationships in the branch which will soon become 0.06)

- allows multiple connections to the same db schema due to not getting its 
connection from classdata

- much easier to extend since the core is substantially more modular

- SQL::Translator support both ways (the DBIx::Class test suite will deploy 
itself via SQLT without ever needing a single line of SQL that isn't 
machine-generated)

- resultset orientation makes performing complex queries much, *much* easier 
(I've been told some peoples' code went down by a factor of 10x)

- automagic features are all built on top of primitive APIs so there's 
something to fall back to if the magic doesn't do what you want

- active developer community, many of whom are present on the mailing list and 
IRC channel much of the time

- fork-safe out of the box (and will be thread-safe out of the box too, in the 
next release)

- commercially supported by us, if you need/want that

- oh, yes, and faster. but I've always found being kind to the database is 
more important than being kind to the perl interpreter for any substantial 
system, which is where the join and prefetch stuff comes in

-- 
      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 Catalyst mailing list