Is it not possible to order joined searches by timestamp with DBIx::Class? I have a SQLite table with created and updated columns that are of the type timestamp. I have a search:
sub get_latest_by_category {
my ( $self, $id, $rows ) = @_;
return $self->search(
{
'category.id' => $id,
'me.published' => 1,
},
{
join => { 'artist_categories' => 'category' },
order_by => { -desc => 'me.created' },
rows => $rows,
}
);
}
It returns the data sorted by the name column in ascending order, which is the first column after the primary key, rather than by the created column in descending order. I can order by created in non-joined searches, and if I change me.created to another column in the above search, it'll return the results in the correct sort order and direction. It just won't do it with a joined search ordered by a timestamp column.
A DBIC_TRACE shows that it's reading the query correctly "ORDER BY me.created DESC". Is there something special about this type of search? Or if this is a limitation, is there an easy way around it?
UPDATE: Ah, never mind. I discovered where the error was. It was a problem with the test database.