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