85ca3e88bf1b8a1120e283ef6b106b8dec08d989
[dbsrgits/DBIx-Class.git] / t / sqlahacks / limit_dialects / rownum.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5
6 use lib qw(t/lib);
7 use DBICTest;
8 use DBIC::SqlMakerTest;
9
10 my $s = DBICTest->init_schema (no_deploy => 1, );
11 $s->storage->sql_maker->limit_dialect ('RowNum');
12
13 my $rs = $s->resultset ('CD');
14
15 is_same_sql_bind (
16   $rs->search ({}, { rows => 1, offset => 3,columns => [
17       { id => 'foo.id' },
18       { 'bar.id' => 'bar.id' },
19       { bleh => \ 'TO_CHAR (foo.womble, "blah")' },
20     ]})->as_query,
21   '(SELECT id, bar__id, bleh
22       FROM (
23         SELECT id, bar__id, bleh, ROWNUM rownum__index
24           FROM (
25             SELECT foo.id AS id, bar.id AS bar__id, TO_CHAR(foo.womble, "blah") AS bleh
26               FROM cd me
27           ) me
28       ) me
29     WHERE rownum__index BETWEEN 4 AND 4
30   )',
31   [],
32   'Rownum subsel aliasing works correctly'
33 );
34
35 done_testing;