[CDBI] Re: has_many relationships and order_by

Edward J. Sabol sabol at alderaan.gsfc.nasa.gov
Wed Dec 14 21:43:49 GMT 2005


> I've encountered a problem with has_many relationships in Class::DBI, after
> upgrading from 0.96 to 3.0.12. Once upon a time, calling:-
>
>      my $iter = $object->children({order_by => "name"})
>
> where "children" is a "has_many" relationship would work nicely, and you
> would get a list/iterator back which would contain your data, all nicely
> sorted.
>
> Now, however, I get an error stating that:- "order_by is not a column of
> Person"
>
> I'm just wondering if this has been changed on purpose, or whether to
> report it as a bug. I can send a test case (using DBD::SQLite2) if
> needed.

I'm guessing it's probably an unintended side effect of this line of code in
_hm_run_search() in Class::DBI::Relationship::HasMany:

    @search_args = %{ $search_args[0] } if ref $search_args[0] eq "HASH";

It's not clear to my why that line was added.

I recommend that you submit a bug report for this issue on
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Class-DBI. You should attach a
failing test case (i.e., a patch to one of the t/*.t files in the
distribution) to your bug report if you want Tony to take quick action.

Hope this helps,
Ed




More information about the ClassDBI mailing list