Commit | Line | Data |
70350518 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
eef2ff6c |
7 | |
8 | my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/}; |
9 | |
10 | #warn "$dsn $user $pass"; |
11 | |
70350518 |
12 | plan skip_all => 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test' |
eef2ff6c |
13 | unless ($dsn); |
14 | |
15 | plan tests => 4; |
16 | |
3885cff6 |
17 | DBICTest::Schema->storage_type('::DBI::MSSQL'); |
58d387fe |
18 | DBICTest::Schema->compose_connection( 'MSSQLTest' => $dsn, $user, $pass ); |
eef2ff6c |
19 | |
20 | my $dbh = MSSQLTest->schema->storage->dbh; |
21 | |
22 | $dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL |
23 | DROP TABLE artist"); |
24 | |
25 | $dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(255));"); |
26 | |
27 | MSSQLTest::Artist->load_components('PK::Auto::MSSQL'); |
28 | |
29 | # Test PK |
30 | my $new = MSSQLTest::Artist->create( { name => 'foo' } ); |
31 | ok($new->artistid, "Auto-PK worked"); |
32 | |
33 | # Test LIMIT |
34 | for (1..6) { |
35 | MSSQLTest::Artist->create( { name => 'Artist ' . $_ } ); |
36 | } |
37 | |
38 | my $it = MSSQLTest::Artist->search( { }, |
39 | { rows => 3, |
40 | offset => 2, |
41 | order_by => 'artistid' |
42 | } |
43 | ); |
44 | |
45 | is( $it->count, 3, "LIMIT count ok" ); |
f48dd03f |
46 | ok( $it->next->name, "iterator->next ok" ); |
eef2ff6c |
47 | $it->next; |
48 | $it->next; |
49 | is( $it->next, undef, "next past end of resultset ok" ); |
50 | |