[Dbix-class] ping 'from' attribute doc author: you need to fix them

Matt S Trout dbix-class at trout.me.uk
Wed May 10 21:23:16 CEST 2006


Toby Corkindale wrote:
> On Wed, May 10, 2006 at 10:00:07AM -0700, Aran Deltac wrote:
>>>> Can whoever originally wrote this step up and correct it please?
>>> And perhaps add another couple of tests to your test suite?
>> Toby - would you be willing to create these?
> 
> If someone can provide documentation that explains how it *should* work, then I
> will happily write some tests based on the docs. Probably a good test of the
> docs that way too :)
> 
> I think what we hit yesterday is a classic example of what happens when coders
> write their own tests.  The tests always work, because they're using the
> library the way the coder imagines.. ie. not neccessarily the way users who
> haven't read the code will try and use it.

Not really, the tests are fine and reasonably comprehensive. The problem 
was that the top bit of the docs ommitted to mention that the bit it 
described was the JOIN syntax and you needed to provide an { 'alias' => 
'table' } on its own first. I've updated the docs in my checkout to read -

C<join> will usually do what you need and it is strongly recommended 
that you
avoid using C<from> unless you cannot achieve the desired result using 
C<join>.
And we really do mean "cannot", not just tried and failed. Attempting to use
this because you're having problems with C<join> is like trying to use x86
ASM because you've got a syntax error in your C. Trust us on this.

Now, if you're still really, really sure you need to use this (and if you're
not 100% sure, ask the mailing list first), here's an explanation of how 
this
works.

The syntax is as follows -

   [
     { <alias1> => <table1> },
     [
       { <alias2> => <table2>, -join_type => 'inner|left|right' },
       [], # nested JOIN (optional)
       { <table1.column1> => <table2.column2>, ... (more conditions) },
     ],
     # More of the above [ ] may follow for additional joins
   ]

   <table1> <alias1>
   JOIN
     <table2> <alias2>
     [JOIN ...]
   ON <table1.column1> = <table2.column2>
   <more joins may follow>


If people can look over that and verify that it (a) makes sense, and (b) 
is actually right, I'll commit that and it'll go out in the next release.



More information about the Dbix-class mailing list