[Dbix-class] Help needed to get a much needed feature into DBIC (low barrier to entry)

Peter Rabbitson rabbit+dbic at rabbit.us
Fri Jan 10 06:11:22 GMT 2014


On Fri, Jan 10, 2014 at 04:47:56PM +1100, neil.lunn wrote:
> On 10/01/2014 3:55 PM, Peter Rabbitson wrote:
> >On Fri, Jan 10, 2014 at 03:08:54PM +1100, neil.lunn wrote:
> >>Just to clarify. Is the objective here to 'flatten out' a single
> >>element array for any key with a "-" prefix only or is it wanted
> >>that anything that is a single element arrayref no longer being an
> >>arrayref, but just what it contains.
> >I have to admit you lost me... Can you give an example of
> >"left/right/result" the way *you* understand it, then it will be trivial
> >to answer your question.
>
> Current test cases are showing an expected result of :
> [{ artist => { '-foo' => 1 }}]
> and getting a result of:
> [{ artist => [ { '-foo' => [ 1 ] } ]}]

I must be blind - I do not see a test like this. Please tell me which line.

> This implies reducing any lists that only have one element to simply
> being that element.
> Also, given that case this seems unclear (at line 284) Expected:
> [{ artist => { '-xyzzy' => undef, tour_manager => [ 'venue',
> 'roadie' ]} }, 'cd']
> and result:
> [{ artist => [{ '-xyzzy' => undef }, { tour_manager => [ 'venue',
> 'roadie' ] } ]}, 'cd' ]

Basically "anything that starts with - is untouched, and passed as-is as 
a member of the hashref of its parent" is what it boils down to. If a 
user supplies -x => [] - it remains, if a user supplies -x => [undef] - it
also remains as is. No special treatment of "options".

Please ask more if it is unclear (or if you see a conflicting test)

> Also not sure the coding on test failing at 252 is right in the
> expected result.

Hm hm hm hm... I think this is actually tickling an incosistency bug in
the *current* code. The following two should give identical results, yet
they do not. 

A)
perl -MDBIx::Class::ResultSet -MDevel::Dwarn -e 'Ddie(
  DBIx::Class::ResultSet->_merge_joinpref_attr(
    [ { artist => undef }, { artist => { "manager" => undef } } ],
    { artist => { manager => [ { artist => {} }, "label" ] } } ,
  )
)'

B)
perl -MDBIx::Class::ResultSet -MDevel::Dwarn -e 'Ddie(
  DBIx::Class::ResultSet->_merge_joinpref_attr(
    [ { artist => undef }, { artist => [{ "manager" => undef }] } ],
    { artist => { manager => [ { artist => {} }, "label" ] } } ,
  )
)'

I *think* the the result of A) should happen in *both* cases. Do you 
agree? If yes - go forward under this assumption, and I will worry about 
backcompat warnings and stuff separately.

Cheers and thanks for looking into this!




More information about the DBIx-Class mailing list