[Dbix-class] using distinct and literal SQL in select list
does not work
Marc Mims
marc at questright.com
Tue Oct 14 16:33:13 BST 2008
* BUCHMULLER Norbert <norbi.lists at nix.hu> [081014 08:20]:
> maybe it's a known issue, nevertheless, it's annoying.. The code below
> throws an exception:
>
> $schema->resultset('Artist')->search(
> {
> },
> {
> select => [ \'1 AS one' ],
> distinct => 1,
> }
> )->first;
>
> The exception:
>
> DBIx::Class::ResultSet::first(): DBI Exception: DBD::Pg::st execute
> failed: ERROR: syntax error at or near "AS" at character 43 [for
> Statement "SELECT 1 AS one FROM artist me GROUP BY 1 AS one"] at test.pl
> line 31
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
-Marc
More information about the DBIx-Class
mailing list