7 use DBIC::SqlMakerTest;
9 my $schema = DBICTest->init_schema;
11 # Trick the sqlite DB to use Top limit emulation
12 delete $schema->storage->_sql_maker->{_cached_syntax};
13 $schema->storage->_sql_maker->limit_dialect ('Top');
15 my $rs = $schema->resultset ('FourKeys')->search ({}, { rows => 1, offset => 3 });
20 my $req_order = $args->{order_req}
21 ? "ORDER BY $args->{order_req}"
26 $rs->search ({}, {order_by => $args->{order_by}})->as_query,
30 SELECT TOP 4 me.foo, me.bar, me.hello, me.goodbye, me.sensors, me.read_count FROM fourkeys me ORDER BY $args->{order_inner}
31 ) foo ORDER BY $args->{order_outer}
41 order_by => \ 'foo DESC',
42 order_req => 'foo DESC',
43 order_inner => 'foo DESC',
44 order_outer => 'foo ASC'
47 order_by => { -asc => 'foo' },
48 order_req => 'foo ASC',
49 order_inner => 'foo ASC',
50 order_outer => 'foo DESC',
55 order_inner => 'foo ASC',
56 order_outer => 'foo DESC',
59 order_by => [ qw{ foo bar} ],
60 order_req => 'foo, bar',
61 order_inner => 'foo ASC,bar ASC',
62 order_outer => 'foo DESC, bar DESC',
65 order_by => { -desc => 'foo' },
66 order_req => 'foo DESC',
67 order_inner => 'foo DESC',
68 order_outer => 'foo ASC',
71 order_by => ['foo', { -desc => 'bar' } ],
72 order_req => 'foo, bar DESC',
73 order_inner => 'foo ASC, bar DESC',
74 order_outer => 'foo DESC, bar ASC',
77 order_by => { -asc => [qw{ foo bar }] },
78 order_req => 'foo ASC, bar ASC',
79 order_inner => 'foo ASC, bar ASC',
80 order_outer => 'foo DESC, bar DESC',
85 { -desc => [qw{bar}] },
86 { -asc => [qw{hello sensors}]},
88 order_req => 'foo ASC, bar DESC, hello ASC, sensors ASC',
89 order_inner => 'foo ASC, bar DESC, hello ASC, sensors ASC',
90 order_outer => 'foo DESC, bar ASC, hello DESC, sensors DESC',
95 order_inner => 'foo ASC, bar ASC, hello ASC, goodbye ASC',
96 order_outer => 'foo DESC, bar DESC, hello DESC, goodbye DESC',
101 order_inner => 'foo ASC, bar ASC, hello ASC, goodbye ASC',
102 order_outer => 'foo DESC, bar DESC, hello DESC, goodbye DESC',
107 order_inner => 'foo ASC, bar ASC, hello ASC, goodbye ASC',
108 order_outer => 'foo DESC, bar DESC, hello DESC, goodbye DESC',
113 order_inner => 'foo ASC, bar ASC, hello ASC, goodbye ASC',
114 order_outer => 'foo DESC, bar DESC, hello DESC, goodbye DESC',
118 plan (tests => scalar @tests);
119 test_order ($_) for @tests;