It works ! Thank you !
By the way, I tried to better understand why you mentioned there was a 'GROUP BY' statement that was being applied. I just understood that this code:
$c->model('Database1')->resultset('Table1')->search(
undef,
{
select => ['group'],
distinct => 1,
order_by => ['group']
},
)
generates this SQL, featuring a GROUP BY:
SELECT group FROM table1 me GROUP BY group ORDER BY group
For me, this feels strange. Writting
distinct => 1
in the query adds a GROUP BY statement. I just found the semantics of 'distinct' in the DBIx::Class::ResultSet documentation but, still, this is counter-intuitive in my opinion. So, thanks for pointing this out... ;-)
Now, this code:
$c->model('Database1')->resultset('Table1')->search(
undef,
{
select => [
{
distinct => 'group'
},
],
as => 'group',
order_by => ['group']
},
)
generates this SQL:
SELECT DISTINCT( group ) FROM table1 me ORDER BY group
This second code is more like what I was looking for... Apparently the trick was to add a
as => '...'
clause in the query...
Thanks again ! |