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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.