[Dbix-class] using distinct and literal SQL in select list does
not work
BUCHMULLER Norbert
norbi.lists at nix.hu
Tue Oct 14 19:24:39 BST 2008
On Tue, 14 Oct 2008 08:33:13 -0700 Marc Mims <marc at questright.com> wrote:
> Try:
>
> my $row = $schema->resultset('Artist')->search(
> {
> },
> {
> select => [ \'1' ],
> as => [qw/one/],
> distinct => 1,
> }
> )->first;
>
> # SQL: SELECT 1 FROM artist me GROUP BY 1
> print $row->get_column('one');
> # output: 1
Thanks, I know that, but that way I cannot use the column name in an
'order_by':
$schema->resultset('Artist')->search(
{
},
{
select => [ \'1' ],
as => [qw/one/],
distinct => 1,
order_by => [ 'one' ],
}
)->first;
This throws:
DBIx::Class::ResultSet::first(): DBI Exception: DBD::Pg::st execute
failed: ERROR: column "one" does not exist at character 45 [for
Statement "SELECT 1 FROM artist me GROUP BY 1 ORDER BY one"] at test.pl
line 31
norbi
More information about the DBIx-Class
mailing list