X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F745db2.t;fp=t%2F745db2.t;h=02998168e70c3bd974e3273a2fb24932572718ea;hb=96eacdb705e37cca2a5a420ec92e353d0d8823b9;hp=c32352989429282a7fdd8948704d5c42a85cffe4;hpb=90cfe42b94a798be8ee5498fd57e2e76adff5156;p=dbsrgits%2FDBIx-Class.git diff --git a/t/745db2.t b/t/745db2.t index c323529..0299816 100644 --- a/t/745db2.t +++ b/t/745db2.t @@ -3,6 +3,7 @@ use warnings; use Test::More; use Test::Exception; +use Try::Tiny; use lib qw(t/lib); use DBICTest; @@ -17,6 +18,23 @@ my $schema = DBICTest::Schema->connect($dsn, $user, $pass); my $dbh = $schema->storage->dbh; +# test RNO and name_sep detection +my $name_sep = $dbh->get_info(41); + +is $schema->storage->sql_maker->name_sep, $name_sep, + 'name_sep detection'; + +my $have_rno = try { + $dbh->selectrow_array( +"SELECT row_number() OVER (ORDER BY 1) FROM sysibm${name_sep}sysdummy1" + ); + 1; +}; + +is $schema->storage->sql_maker->limit_dialect, + ($have_rno ? 'RowNumberOver' : 'FetchFirst'), + 'limit_dialect detection'; + eval { $dbh->do("DROP TABLE artist") }; $dbh->do("CREATE TABLE artist (artistid INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), name VARCHAR(255), charfield CHAR(10), rank INTEGER DEFAULT 13);"); @@ -85,6 +103,25 @@ is( $lim->next->artistid, 101, "iterator->next ok" ); is( $lim->next->artistid, 102, "iterator->next ok" ); is( $lim->next, undef, "next past end of resultset ok" ); +# test FetchFirst limit dialect syntax +{ + local $schema->storage->sql_maker->{limit_dialect} = 'FetchFirst'; + + my $lim = $ars->search({}, { + rows => 3, + offset => 2, + order_by => 'artistid', + }); + + is $lim->count, 3, 'fetch first limit count ok'; + + is $lim->all, 3, 'fetch first number of ->all objects matches count'; + + is $lim->next->artistid, 3, 'iterator->next ok'; + is $lim->next->artistid, 66, 'iterator->next ok'; + is $lim->next->artistid, 101, 'iterator->next ok'; + is $lim->next, undef, 'iterator->next past end of resultset ok'; +} my $test_type_info = { 'artistid' => {