[jifty-devel] Jifty::DBI order_by unclear

Andreas J. Koenig andreas.koenig.7os6VVqR at franz.ak.mind.de
Mon May 28 10:34:00 EDT 2007

I wonder if I am the only one who has difficutlties understanding the
order_by clause or the only one who wants to use it with joined
tables. Reading of neither the pod nor the source does lead me to a
solution, so I must ask on the list:

I have two tables: sessions and testruns. Testruns happen within a
session, so there is a 1:N relation of sessions to testruns. Testrun's
schema contains:

  package Pocpoc::Model::Testrun;
  use Jifty::DBI::Schema;
  use Pocpoc::Record schema {
    column testsession =>
        references Pocpoc::Model::Session;

and the Session's schema has, among others

  package Pocpoc::Model::Session;
  use Jifty::DBI::Schema;
  use Pocpoc::Record schema {
    column starttime =>
          type is 'varchar',
          max_length is 15,
          label is 'Session',
        default is 'not supposed to be inserted manually!';

This worked as expected intuitively very well until I wanted to sort a
list of testruns by the session's starttime. Since that moment I'm
stuck and simply cannot figure out how it is supposed to work.

Even with the help of build_select_query() I could not get close to a
solution that builds the query in a way that can be used to get the
value that I want to use for order_by.

Any help greatly appreciated...Thanks!

More information about the jifty-devel mailing list