[Dbix-class] Unexpected ORDER BY in query

Ben Staude sben1783 at yahoo.de
Fri Jan 5 15:38:39 GMT 2007


Am Freitag 05 Januar 2007 15:37 schrieb Matt S Trout:
> On 5 Jan 2007, at 14:22, Ben Staude wrote:
> > Hi all,
> >
> > I hope my question can be answered "generally" so I don't have to
> > go too much
> > into the details of my dbic setup...
> >
> > Here's my problem:
> > I select rows in a table and use prefetch to also select a has_many
> > relationship. The select itself is ok, but it contains an "ORDER BY"
> > statement that I can't explain. It orders by the first column of the
> > connection table.
> >
> > I eliminated every order_by in the project's complete source code;
> > it didn't
> > help. I don't use sort_column() anywhere.
> >
> > If I add an order_by to the ResultSet attributes, this column is
> > added to the
> > ORDER BY in front of the "unwanted" sort-column.
>
> This is added so the has_many prefetch returns are produced in the
> right order, which makes things much more efficient and allows $rs-
>  >next to work with has_many prefetch. Since your explicit order_by
> happens first, it should make no difference to the results you get,
> it just makes it a lot more efficient for DBIC to get them for you.

Ok, so no more worries about a broken schema needed... Glad I canceled 
my "bug"-search and asked;-)

Thank you -
Ben

		
___________________________________________________________ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de




More information about the Dbix-class mailing list