Deprecate emulate_limit() - can not be sanely supported by DQ
[dbsrgits/DBIx-Class.git] / t / sqlmaker / limit_dialects / custom.t
CommitLineData
d5dedbd6 1use strict;
2use warnings;
3
4use Test::More;
67341081 5use Test::Warn;
d5dedbd6 6
7use lib qw(t/lib);
d9c17594 8use DBICTest;
d5dedbd6 9use DBICTest::Schema;
10use 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}
d9c17594 27my $s = DBICTest::Schema->connect (DBICTest->_database);
d5dedbd6 28$s->storage->sql_maker_class ('DBICTest::SQLMaker::CustomDialect');
29
30my $rs = $s->resultset ('CD');
67341081 31
32warnings_exist { is_same_sql_bind (
d5dedbd6 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'
67341081 50 )}
51 qr/\Qthe legacy emulate_limit() mechanism inherited from SQL::Abstract::Limit has been deprecated/,
52 'deprecation warning'
53;
d5dedbd6 54
55done_testing;