DBIx::Class::Schema::Loader::DBI::MSSQL
/;
use mro 'c3';
+use DBIx::Class::Schema::Loader::Utils qw/sigwarn_silencer/;
+
+use namespace::clean;
our $VERSION = '0.07036_02';
# Silence ADO "Changed database context" warnings
sub _switch_db {
my $self = shift;
- my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
- local $SIG{__WARN__} = sub {
- $warn_handler->(@_) unless $_[0] =~ /Changed database context/;
- };
+ local $SIG{__WARN__} = sigwarn_silencer(qr/Changed database context/);
return $self->next::method(@_);
}
use base 'DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault';
use mro 'c3';
use Try::Tiny;
+use DBIx::Class::Schema::Loader::Utils qw/sigwarn_silencer/;
use namespace::clean;
our $VERSION = '0.07036_02';
my $self = shift;
# silence a warning from older DBD::Oracles in tests
- my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
- local $SIG{__WARN__} = sub {
- $warn_handler->(@_)
- unless $_[0] =~ /^Field \d+ has an Oracle type \(\d+\) which is not explicitly supported/;
- };
+ local $SIG{__WARN__} = sigwarn_silencer(
+ qr/^Field \d+ has an Oracle type \(\d+\) which is not explicitly supported/
+ );
return $self->next::method(@_);
}
use List::MoreUtils 'any';
use Try::Tiny;
use Scalar::Util 'blessed';
+use DBIx::Class::Schema::Loader::Utils qw/sigwarn_silencer/;
use namespace::clean;
use DBIx::Class::Schema::Loader::Table ();
sub _dbh_column_info {
my $self = shift;
- local $SIG{__WARN__} = sub { warn @_
- unless $_[0] =~ /^column_info: unrecognized column type/ };
+ local $SIG{__WARN__} = sigwarn_silencer(
+ qr/^column_info: unrecognized column type/
+ );
$self->next::method(@_);
}
use Try::Tiny;
use File::Path 'rmtree';
use DBIx::Class::Schema::Loader 'make_schema_at';
+use DBIx::Class::Schema::Loader::Utils qw/sigwarn_silencer/;
use namespace::clean;
use DBI ();
};
try {
- my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
- local $SIG{__WARN__} = sub {
- $warn_handler->(@_)
- unless $_[0] =~ /^Password correctly set\.$|^Account unlocked\.$|^New login created\.$|^New user added\.$/;
- };
+ local $SIG{__WARN__} = sigwarn_silencer(
+ qr/^Password correctly set\.$|^Account unlocked\.$|^New login created\.$|^New user added\.$/
+ );
$dbh->do("sp_addlogin dbicsl_user1, dbicsl, [dbicsl_test1]");
$dbh->do("sp_addlogin dbicsl_user2, dbicsl, [dbicsl_test2]");
my ($dbh1, $dbh2);
{
- my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
- local $SIG{__WARN__} = sub {
- $warn_handler->(@_) unless $_[0] =~ /can't change context/;
- };
-
+ local $SIG{__WARN__} = sigwarn_silencer(
+ qr/can't change context/
+ );
$dbh1 = DBI->connect($dsn, 'dbicsl_user1', 'dbicsl', {
RaiseError => 1,
PrintError => 0,
foreach my $login (qw/dbicsl_user1 dbicsl_user2/) {
try {
- my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
- local $SIG{__WARN__} = sub {
- $warn_handler->(@_)
- unless $_[0] =~ /^Account locked\.$|^Login dropped\.$/;
- };
+ local $SIG{__WARN__} = sigwarn_silencer(
+ qr/^Account locked\.$|^Login dropped\.$/
+ );
$dbh->do("sp_droplogin $login");
}
use warnings;
use Test::More;
use Test::Exception;
-use DBIx::Class::Schema::Loader::Utils 'warnings_exist_silent';
+use DBIx::Class::Schema::Loader::Utils qw/warnings_exist_silent sigwarn_silencer/;
use Try::Tiny;
use File::Path 'rmtree';
use DBIx::Class::Schema::Loader 'make_schema_at';
SKIP: {
# for ADO
- my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
- local $SIG{__WARN__} = sub {
- $warn_handler->(@_) unless $_[0] =~ /Changed database context/;
- };
+ local $SIG{__WARN__} = sigwarn_silencer(
+ qr/Changed database context/
+ );
my $dbh = $schema->storage->dbh;
return if $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP};
# for ADO
- my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
- local $SIG{__WARN__} = sub {
- $warn_handler->(@_) unless $_[0] =~ /Changed database context/;
- };
+ local $SIG{__WARN__} = sigwarn_silencer(
+ qr/Changed database context/
+ );
my $dbh = $schema->storage->dbh;
use warnings;
use Test::More;
use Scope::Guard ();
+use DBIx::Class::Schema::Loader::Utils qw/sigwarn_silencer/;
use lib qw(t/lib);
use dbixcsl_common_tests;
else {
# get rid of stupid warning from InterBase/GetInfo.pm
if ($dbd_interbase_dsn) {
- local $SIG{__WARN__} = sub { warn @_
- unless $_[0] =~ m{^Use of uninitialized value in sprintf at \S+DBD/InterBase/GetInfo\.pm line \d+\.$|^Missing argument in sprintf at \S+DBD/InterBase/GetInfo.pm line \d+\.$} };
+ local $SIG{__WARN__} = sigwarn_silencer(
+ qr{^Use of uninitialized value in sprintf at \S+DBD/InterBase/GetInfo\.pm line \d+\.$|^Missing argument in sprintf at \S+DBD/InterBase/GetInfo.pm line \d+\.$}
+ );
require DBD::InterBase;
require DBD::InterBase::GetInfo;
}
use Test::More;
use Test::Warn;
use DBIx::Class::Schema::Loader::Optional::Dependencies;
+use DBIx::Class::Schema::Loader::Utils qw/sigwarn_silencer/;
use lib qw(t/lib);
use make_dbictest_db;
my $cref = shift @invocations;
my $schema = do {
- local $SIG{__WARN__} = sub {
- warn $_[0] unless $_[0] =~ /Deleting existing file .+ due to 'really_erase_my_files' setting/
- };
+ local $SIG{__WARN__} = sigwarn_silencer(
+ qr/Deleting existing file .+ due to 'really_erase_my_files' setting/
+ );
$cref->();
};
use Digest::MD5;
use File::Find 'find';
use Class::Unload ();
-use DBIx::Class::Schema::Loader::Utils qw/dumper_squashed slurp_file/;
+use DBIx::Class::Schema::Loader::Utils qw/dumper_squashed slurp_file sigwarn_silencer/;
use List::MoreUtils 'apply';
use DBIx::Class::Schema::Loader::Optional::Dependencies ();
use Try::Tiny;
# relname is preserved when another fk is added
{
- local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /invalidates \d+ active statement/ };
+ local $SIG{__WARN__} = sigwarn_silencer(qr/invalidates \d+ active statement/);
$conn->storage->disconnect; # for mssql and access
}
my $guard = $conn->txn_scope_guard;
- my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
- local $SIG{__WARN__} = sub {
- $warn_handler->(@_)
- unless $_[0] =~ RESCAN_WARNINGS
- || $_[0] =~ /commit ineffective with AutoCommit enabled/; # FIXME
- };
+ my $rescan_warnings = RESCAN_WARNINGS;
+ local $SIG{__WARN__} = sigwarn_silencer(
+ qr/$rescan_warnings|commit ineffective with AutoCommit enabled/ # FIXME
+ );
my $schema_from = DBIx::Class::Schema::Loader::make_schema_at(
"TestSchemaFromAnother", \%opts, [ sub { $conn->storage->dbh } ]
sub rescan_without_warnings {
my ($self, $conn) = @_;
- local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ RESCAN_WARNINGS };
+ local $SIG{__WARN__} = sigwarn_silencer(RESCAN_WARNINGS);
return $conn->rescan;
}