Deprecate emulate_limit() - can not be sanely supported by DQ
[dbsrgits/DBIx-Class.git] / t / sqlmaker / limit_dialects / custom.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Warn;
6
7 use lib qw(t/lib);
8 use DBICTest;
9 use DBICTest::Schema;
10 use DBIC::SqlMakerTest;
11
12 # This is legacy stuff from SQL::Absract::Limit
13 # Keep it around just in case someone is using it
14
15 {
16   package DBICTest::SQLMaker::CustomDialect;
17   use base qw/DBIx::Class::SQLMaker/;
18   sub emulate_limit {
19     my ($self, $sql, $rs_attrs, $limit, $offset) = @_;
20     return sprintf ('shiny sproc ((%s), %d, %d)',
21       $sql,
22       $limit || 0,
23       $offset || 0,
24     );
25   }
26 }
27 my $s = DBICTest::Schema->connect (DBICTest->_database);
28 $s->storage->sql_maker_class ('DBICTest::SQLMaker::CustomDialect');
29
30 my $rs = $s->resultset ('CD');
31
32 warnings_exist { is_same_sql_bind (
33   $rs->search ({}, { rows => 1, offset => 3,columns => [
34       { id => 'foo.id' },
35       { 'bar.id' => 'bar.id' },
36       { bleh => \ 'TO_CHAR (foo.womble, "blah")' },
37     ]})->as_query,
38   '(
39     shiny sproc (
40       (
41         SELECT foo.id, bar.id, TO_CHAR (foo.womble, "blah")
42           FROM cd me
43       ),
44       1,
45       3
46     )
47   )',
48   [],
49   'Rownum subsel aliasing works correctly'
50  )}
51   qr/\Qthe legacy emulate_limit() mechanism inherited from SQL::Abstract::Limit has been deprecated/,
52   'deprecation warning'
53 ;
54
55 done_testing;