5 use DBIx::Class::Storage::DBI;
7 use DBICTest; # do not remove even though it is not used
8 use DBIC::SqlMakerTest;
12 my $sa = new DBIx::Class::SQLAHacks;
13 $sa->limit_dialect( 'Top' );
17 my $order_by = $args->{order_by};
18 my $expected_sql_order = $args->{expected_sql_order};
20 my $query = $sa->select( 'foo', [qw{bar baz}], undef, {
21 order_by => $order_by,
26 "SELECT * FROM ( SELECT TOP 1 * FROM ( SELECT TOP 4 bar,baz FROM foo ORDER BY $expected_sql_order->[0] ) AS foo ORDER BY $expected_sql_order->[1] ) AS bar ORDER BY $expected_sql_order->[0]",
30 test_order({ order_by => \'foo DESC' , expected_sql_order => [ 'foo DESC', 'foo ASC' ] });
31 test_order({ order_by => 'foo' , expected_sql_order => [ 'foo ASC', 'foo DESC'] });
32 test_order({ order_by => [ qw{ foo bar} ], expected_sql_order => [ 'foo ASC,bar ASC', 'foo DESC, bar DESC']});
33 test_order({ order_by => { -asc => 'foo' }, expected_sql_order => [ 'foo ASC', 'foo DESC' ] });
34 test_order({ order_by => { -desc => 'foo' }, expected_sql_order => [ 'foo DESC', 'foo ASC' ] });
36 test_order({ order_by => ['foo', { -desc => 'bar' } ], expected_sql_order => [ 'foo ASC, bar DESC', 'foo DESC, bar ASC'] });
37 test_order({ order_by => {-asc => [qw{ foo bar }] }, expected_sql_order => ['foo ASC, bar ASC', 'foo DESC, bar DESC' ] });
38 test_order({ order_by =>
41 { -desc => [qw{bar}] },
42 { -asc => [qw{baz frew}]},
44 expected_sql_order => ['foo ASC, bar DESC, baz ASC, frew ASC', 'foo DESC, bar ASC, baz DESC, frew DESC']