Make test suite pass under DBICTEST_SQLITE_USE_FILE=1
[dbsrgits/DBIx-Class.git] / t / sqlmaker / limit_dialects / custom.t
CommitLineData
d5dedbd6 1use strict;
2use warnings;
3
4use Test::More;
5
6use lib qw(t/lib);
d9c17594 7use DBICTest;
d5dedbd6 8use DBICTest::Schema;
9use DBIC::SqlMakerTest;
10
11# This is legacy stuff from SQL::Absract::Limit
12# Keep it around just in case someone is using it
13
14{
15 package DBICTest::SQLMaker::CustomDialect;
16 use base qw/DBIx::Class::SQLMaker/;
17 sub emulate_limit {
18 my ($self, $sql, $rs_attrs, $limit, $offset) = @_;
19 return sprintf ('shiny sproc ((%s), %d, %d)',
20 $sql,
21 $limit || 0,
22 $offset || 0,
23 );
24 }
25}
d9c17594 26my $s = DBICTest::Schema->connect (DBICTest->_database);
d5dedbd6 27$s->storage->sql_maker_class ('DBICTest::SQLMaker::CustomDialect');
28
29my $rs = $s->resultset ('CD');
30is_same_sql_bind (
31 $rs->search ({}, { rows => 1, offset => 3,columns => [
32 { id => 'foo.id' },
33 { 'bar.id' => 'bar.id' },
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'
48);
49
50done_testing;