[Dbix-class] using distinct and literal SQL in select list does not work

BUCHMULLER Norbert norbi.lists at nix.hu
Wed Oct 15 13:58:59 BST 2008


On Tue, 14 Oct 2008 12:09:52 -0700 Marc Mims <marc at questright.com> wrote:

> Are you sure you need the "as" alias for the order by?  The example you
> gave to demonstrate the problem is perhaps too trivial.

Yeah, I tried to limit it to the bare bones necessary to reproduce the
problem. :-)

In the scenario I have there's a method (of a custom resultset object)
that takes a resultset ($self) and returns a resultset. The users of this
method need not know about the details, they just use the returned
resultset in further search() calls and simply use the additional column
added by the method. Even in an 'order_by' attribute. It would be very
inconvenient if I had to pass the SQL string used to construct the extra
column.. (And the method not only adds this column, but adds conditions
to the resultset, so simply moving the code that generates the extra
column into a function is not enough here.)

Now, the above setup works fine - up to the point when I use 'distinct'
in a search(). (In fact, there's another problem with it, using '+select'
on the resultset clears the previous columns added by '+select' - see the
other thread I started.)

norbi



More information about the DBIx-Class mailing list