File: rownum.t

package info (click to toggle)
libdbix-class-perl 0.08123-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,520 kB
  • ctags: 1,695
  • sloc: perl: 19,821; sql: 353; makefile: 10
file content (35 lines) | stat: -rw-r--r-- 806 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use strict;
use warnings;

use Test::More;

use lib qw(t/lib);
use DBICTest;
use DBIC::SqlMakerTest;

my $s = DBICTest->init_schema (no_deploy => 1, );
$s->storage->sql_maker->limit_dialect ('RowNum');

my $rs = $s->resultset ('CD');

is_same_sql_bind (
  $rs->search ({}, { rows => 1, offset => 3,columns => [
      { id => 'foo.id' },
      { 'bar.id' => 'bar.id' },
      { bleh => \ 'TO_CHAR (foo.womble, "blah")' },
    ]})->as_query,
  '(SELECT id, bar__id, bleh
      FROM (
        SELECT id, bar__id, bleh, ROWNUM rownum__index
          FROM (
            SELECT foo.id AS id, bar.id AS bar__id, TO_CHAR(foo.womble, "blah") AS bleh
              FROM cd me
          ) me
      ) me
    WHERE rownum__index BETWEEN 4 AND 4
  )',
  [],
  'Rownum subsel aliasing works correctly'
);

done_testing;