[Dbix-class] Auto-joins
Matt S Trout
dbix-class at trout.me.uk
Fri Mar 31 18:51:48 CEST 2006
Nilson Santos Figueiredo Junior wrote:
> On 3/30/06, Matt S Trout <dbix-class at trout.me.uk> wrote:
>> quick example for you from the S::A tests
>>
>> [-maybe => {race => [-and => [qw(black white asian)]]},
>> {-nest => {firsttime => [-or => {'=','yes'}, undef]}},
>> [ -and => {firstname => {-not_like => 'candace'}},
>> {lastname => {-in => [qw(jugs canyon towers)]}} ] ] ]
>>
>> making it work for trivial queries is trivial. making it work for every
>> possible query is more complex :)
>
> Yes. But I think it's better to be able to auto-join simple queries
> than to not do it at all.
Don't like that approach. In my experience magic that doesn't work entirely
tends to be a bad design decision in the long run, since it often fails in odd
ways. Class::DBI's magic drove me insane when it didn't quite work, because I
usually had to bypass it entirely. Which has often far too hard.
> Actually, I'd never write queries like this example.
> Anything that gets a little more complex will, usually, be much more
> readable as plain SQL. I mean, the end of this query looks like Lisp
> on steroids (i.e. with brackets and curly braces besides parens). It's
> damn ugly.
I like lisp :)
> I know this might be seen with some criticism, but I'd rather maintain
> SQL statements than that complex data structures mess and I know this
> query is actually not that complex.
That's great until you need to add an extra chunk to the query
programmatically, at which point stuff gets hard.
> Anyway... why not patching SQL::Abstract? Or is it somehow unpatchable
> (i.e. so badly messed up that you wouldn't touch it with a 10 foot
> pole)?
It would need the best part of a rewrite; the _recurse_where method is kinda
monolithic. Plus I haven't been able to raise the author by e-mail.
--
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