[Dbix-class] select and DISTINCT

Alex Povolotsky tarkhil at over.ru
Tue Jun 11 13:00:03 GMT 2013


On 06/11/13 16:43, Dmitry Belyavsky wrote:

select =3D> ['DISTINCT column'] clearly should not work with DBIx::Class; =

and select distinct does not seems to be supported well.

distinct =3D> 1 does something strange (group by instead of distinct), and =

select =3D> [ distinct =3D> 'column' ] MAYBE will perform as you're expecti=
ng.

> After upgrading the DBIx::Class package from 8.0127 to 8.0196 the =

> problem occurs in using
> select attribute of a ResultSet with DISTINCT qualifier.
>
> I used the syntax
>
>   my $rs_2 =3D $rs->search({},
>       {
>       select =3D> ['DISTINCT searchable_id', "dense_rank() OVER (ORDER =

> BY $order_by) AS pos" ],
>       as     =3D> ['searchable_id', 'pos'],
>       }
>       );
>
> $order_by clause is calculated separately and above.
>
> I get an error
>
> =3D=3D=3D=3D=3D=3D=3D
> DBIx::Class::ResultSet::next(): DBI Exception: DBD::Pg::st execute =

> failed: ERROR:  column me.distinct does not exist
> [Mon Jun 10 17:33:22 2013] [error] LINE 1: SELECT me.pos FROM (SELECT =

> me.DISTINCT searchable_id, dense_rank()...
> =3D=3D=3D=3D=3D=3D=3D
>
> For this particular query I can avoid DISTINCT, but what should I do =

> not ot get this error?
>
> Thank you!
>
> -- =

> SY, Dmitry Belyavsky
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.=
co.uk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20130611/06f=
9e2c8/attachment.htm


More information about the DBIx-Class mailing list