fixed up sqlt tests a bit and tried fixing 2 failing sqlt tests
[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
81092e2d 17my $storage_type = '::DBI::MSSQL';
18$storage_type = '::DBI::Sybase::MSSQL' if $dsn =~ /^dbi:Sybase:/;
19# Add more for others in the future when they exist (ODBC? ADO? JDBC?)
20
21DBICTest::Schema->storage_type($storage_type);
58d387fe 22DBICTest::Schema->compose_connection( 'MSSQLTest' => $dsn, $user, $pass );
eef2ff6c 23
24my $dbh = MSSQLTest->schema->storage->dbh;
25
26$dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL
27 DROP TABLE artist");
28
29$dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(255));");
30
31MSSQLTest::Artist->load_components('PK::Auto::MSSQL');
32
33# Test PK
34my $new = MSSQLTest::Artist->create( { name => 'foo' } );
35ok($new->artistid, "Auto-PK worked");
36
37# Test LIMIT
38for (1..6) {
39 MSSQLTest::Artist->create( { name => 'Artist ' . $_ } );
40}
41
42my $it = MSSQLTest::Artist->search( { },
43 { rows => 3,
44 offset => 2,
45 order_by => 'artistid'
46 }
47);
48
49is( $it->count, 3, "LIMIT count ok" );
f48dd03f 50ok( $it->next->name, "iterator->next ok" );
eef2ff6c 51$it->next;
52$it->next;
53is( $it->next, undef, "next past end of resultset ok" );
54