File: custom.t

package info (click to toggle)
libdbix-class-perl 0.082844-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,320 kB
  • sloc: perl: 27,215; sql: 322; sh: 29; makefile: 16
file content (53 lines) | stat: -rw-r--r-- 1,209 bytes parent folder | download | duplicates (5)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use strict;
use warnings;

use Test::More;
use Test::Warn;

use lib qw(t/lib);
use DBICTest ':DiffSQL';

# This is legacy stuff from SQL::Absract::Limit
# Keep it around just in case someone is using it

{
  package DBICTest::SQLMaker::CustomDialect;
  use base qw/DBIx::Class::SQLMaker/;
  sub emulate_limit {
    my ($self, $sql, $rs_attrs, $limit, $offset) = @_;
    return sprintf ('shiny sproc ((%s), %d, %d)',
      $sql,
      $limit || 0,
      $offset || 0,
    );
  }
}
my $s = DBICTest::Schema->connect (DBICTest->_database);
$s->storage->sql_maker_class ('DBICTest::SQLMaker::CustomDialect');

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

warnings_exist { is_same_sql_bind (
  $rs->search ({}, { rows => 1, offset => 3,columns => [
      { id => 'foo.id' },
      { 'artist.id' => 'bar.id' },
      { bleh => \ 'TO_CHAR (foo.womble, "blah")' },
    ]})->as_query,
  '(
    shiny sproc (
      (
        SELECT foo.id, bar.id, TO_CHAR (foo.womble, "blah")
          FROM cd me
      ),
      1,
      3
    )
  )',
  [],
  'Rownum subsel aliasing works correctly'
 )}
  qr/\Qthe legacy emulate_limit() mechanism inherited from SQL::Abstract::Limit has been deprecated/,
  'deprecation warning'
;

done_testing;