isa_ok($schema->storage, "DBIx::Class::Storage::$storage_type");
-# start disconnected to test reconnection
+# start disconnected to test _ping
$schema->storage->_dbh->disconnect;
- my $dbh;
- lives_ok (sub {
- $dbh = $schema->storage->dbh;
- }, 'reconnect works');
+ lives_ok {
+ $schema->storage->dbh_do(sub { $_[1]->do('select 1') })
+ } '_ping works';
+
+ my $dbh = $schema->storage->dbh;
$dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL
DROP TABLE artist");
is $rs->first, undef, 'rolled back';
$rs->reset;
+
+ # test RNO detection when version detection fails
+ SKIP: {
+ my $storage = $schema->storage;
+ my $version = $storage->_server_info->{normalized_dbms_version};
+
+ skip 1, 'could not detect SQL Server version' if not defined $version;
+
+ my $have_rno = $version >= 9 ? 1 : 0;
+
+ # Delete version information to force RNO check when rebuilding SQLA
+ # instance.
+ no strict 'refs';
+ no warnings 'redefine';
+ local *{(ref $storage).'::_get_server_version'} = sub { undef };
+
+ my $server_info = { %{ $storage->_server_info_hash } }; # clone
+
+ delete @$server_info{qw/dbms_version normalized_dbms_version/};
+
+ local $storage->{_server_info_hash} = $server_info;
+ local $storage->{_sql_maker} = undef;
+ local $storage->{_sql_maker_opts} = undef;
+
+ $storage->sql_maker;
+
+ my $rno_detected =
+ ($storage->{_sql_maker_opts}{limit_dialect} eq 'RowNumberOver');
+
+ ok ((not ($have_rno xor $rno_detected)),
+ 'row_number() over support detected correctly');
+ }
}
# test op-induced autoconnect