fixed rels ending with me breaking subquery realiasing
[dbsrgits/DBIx-Class.git] / t / sqlahacks / limit_dialects / rownum.t
CommitLineData
327368bc 1use strict;
2use warnings;
3
4use Test::More;
5
6use lib qw(t/lib);
7use DBICTest;
8use DBIC::SqlMakerTest;
9
10my $s = DBICTest->init_schema (no_deploy => 1, );
11$s->storage->sql_maker->limit_dialect ('RowNum');
12
13my $rs = $s->resultset ('CD');
14
15is_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
f8583f8f 35is_same_sql_bind (
36 $rs->search ({}, { rows => 1, offset => 3,columns => [
37 { id => 'foo.id' },
38 { 'ends_with_me.id' => 'ends_with_me.id' },
39 ]})->as_query,
40 '(SELECT id, ends_with_me__id
41 FROM (
42 SELECT id, ends_with_me__id, ROWNUM rownum__index
43 FROM (
44 SELECT foo.id AS id, ends_with_me.id AS ends_with_me__id
45 FROM cd me
46 ) me
47 ) me
48 WHERE rownum__index BETWEEN 4 AND 4
49 )',
50 [],
51 'Rownum subsel aliasing works correctly'
52);
53
327368bc 54done_testing;