Revert 2c2bc4e5 - it is entirely superseded by cb551b07, 2baba3d9 and 83eef562
[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);
a5a7bb73 8use DBICTest ':DiffSQL';
d5dedbd6 9
10# This is legacy stuff from SQL::Absract::Limit
11# Keep it around just in case someone is using it
12
13{
14 package DBICTest::SQLMaker::CustomDialect;
15 use base qw/DBIx::Class::SQLMaker/;
16 sub emulate_limit {
17 my ($self, $sql, $rs_attrs, $limit, $offset) = @_;
18 return sprintf ('shiny sproc ((%s), %d, %d)',
19 $sql,
20 $limit || 0,
21 $offset || 0,
22 );
23 }
24}
c7e85630 25my $s = DBICTest::Schema->connect (DBICTest->_database);
d5dedbd6 26$s->storage->sql_maker_class ('DBICTest::SQLMaker::CustomDialect');
27
28my $rs = $s->resultset ('CD');
67341081 29
30warnings_exist { is_same_sql_bind (
d5dedbd6 31 $rs->search ({}, { rows => 1, offset => 3,columns => [
32 { id => 'foo.id' },
95e41036 33 { 'artist.id' => 'bar.id' },
d5dedbd6 34 { bleh => \ 'TO_CHAR (foo.womble, "blah")' },
35 ]})->as_query,
36 '(
37 shiny sproc (
38 (
39 SELECT foo.id, bar.id, TO_CHAR (foo.womble, "blah")
40 FROM cd me
41 ),
42 1,
43 3
44 )
45 )',
46 [],
47 'Rownum subsel aliasing works correctly'
67341081 48 )}
49 qr/\Qthe legacy emulate_limit() mechanism inherited from SQL::Abstract::Limit has been deprecated/,
50 'deprecation warning'
51;
d5dedbd6 52
53done_testing;