From: Peter Rabbitson Date: Thu, 3 Mar 2016 11:24:55 +0000 (+0100) Subject: Do not load DBIC::Optional::Dependencies at runtime unless we need to X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=18a2903b824e3d3159836c99c1ab88058537169f;p=dbsrgits%2FDBIx-Class.git Do not load DBIC::Optional::Dependencies at runtime unless we need to --- diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 1adbe64..cec52f7 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -18,8 +18,6 @@ $VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev relea use DBIx::Class::_Util; use mro 'c3'; -use DBIx::Class::Optional::Dependencies; - use base qw/DBIx::Class::Componentised DBIx::Class::AccessorGroup/; use DBIx::Class::StartupCheck; use DBIx::Class::Exception; diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index 2f130f6..c155360 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -641,6 +641,7 @@ sub _create_db_to_schema_diff { return; } + require DBIx::Class::Optional::Dependencies; if ( my $missing = DBIx::Class::Optional::Dependencies->req_missing_for('deploy') ) { $self->throw_exception("Unable to proceed without $missing"); } diff --git a/lib/DBIx/Class/Storage.pm b/lib/DBIx/Class/Storage.pm index 47aef36..45839e1 100644 --- a/lib/DBIx/Class/Storage.pm +++ b/lib/DBIx/Class/Storage.pm @@ -577,6 +577,7 @@ sub debugobj { if ($profile =~ /^\.?\//) { + require DBIx::Class::Optional::Dependencies; if ( my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('config_file_reader') ) { $self->throw_exception("Unable to parse TRACE_PROFILE config file '$profile' without $missing"); } diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 25ed0b5..cafdf19 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -2938,6 +2938,11 @@ them. sub create_ddl_dir { my ($self, $schema, $databases, $version, $dir, $preversion, $sqltargs) = @_; + require DBIx::Class::Optional::Dependencies; + if (my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('deploy')) { + $self->throw_exception("Can't create a ddl file without $missing"); + } + if (!$dir) { carp "No directory given, using ./\n"; $dir = './'; @@ -2960,10 +2965,6 @@ sub create_ddl_dir { %{$sqltargs || {}} }; - if (my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('deploy')) { - $self->throw_exception("Can't create a ddl file without $missing"); - } - my $sqlt = SQL::Translator->new( $sqltargs ); $sqlt->parser('SQL::Translator::Parser::DBIx::Class'); @@ -3117,6 +3118,7 @@ sub deployment_statements { return join('', @rows); } + require DBIx::Class::Optional::Dependencies; if (my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('deploy') ) { $self->throw_exception("Can't deploy without a pregenerated 'ddl_dir' directory or $missing"); } diff --git a/lib/DBIx/Class/Storage/DBI/Pg.pm b/lib/DBIx/Class/Storage/DBI/Pg.pm index ded6d06..87a237d 100644 --- a/lib/DBIx/Class/Storage/DBI/Pg.pm +++ b/lib/DBIx/Class/Storage/DBI/Pg.pm @@ -181,6 +181,8 @@ sub bind_attribute_by_data_type { ); } elsif ( + require DBIx::Class::Optional::Dependencies + and my $missing = DBIx::Class::Optional::Dependencies->req_missing_for([qw( rdbms_pg binary_data )]) ) { # FIXME - perhaps this needs to be an exception too...? diff --git a/t/52leaks.t b/t/52leaks.t index ca588ce..e54df31 100644 --- a/t/52leaks.t +++ b/t/52leaks.t @@ -33,6 +33,7 @@ use DBICTest::RunMode; use DBICTest::Util::LeakTracer qw(populate_weakregistry assert_empty_weakregistry visit_refs); use Scalar::Util qw(weaken blessed reftype); use DBIx::Class::_Util qw(hrefaddr sigwarn_silencer modver_gt_or_eq modver_gt_or_eq_and_lt); +use DBIx::Class::Optional::Dependencies; my $TB = Test::More->builder; if ($ENV{DBICTEST_IN_PERSISTENT_ENV}) { diff --git a/t/84serialize.t b/t/84serialize.t index bbb5f4e..021c44e 100644 --- a/t/84serialize.t +++ b/t/84serialize.t @@ -61,6 +61,7 @@ my %stores = ( ); SKIP: { + require DBIx::Class::Optional::Dependencies; DBIx::Class::Optional::Dependencies->skip_without('test_memcached'); my $memcached = Cache::Memcached->new( diff --git a/t/lib/DBICTest/Util/LeakTracer.pm b/t/lib/DBICTest/Util/LeakTracer.pm index 134ca63..82ff010 100644 --- a/t/lib/DBICTest/Util/LeakTracer.pm +++ b/t/lib/DBICTest/Util/LeakTracer.pm @@ -7,12 +7,17 @@ use ANFANG; use Carp; use Scalar::Util qw(isweak weaken blessed reftype); use DBIx::Class::_Util qw(refcount hrefaddr refdesc); -use DBIx::Class::Optional::Dependencies; use DBICTest::RunMode; use Data::Dumper::Concise; use DBICTest::Util qw( stacktrace visit_namespaces ); use constant { - CV_TRACING => !DBICTest::RunMode->is_plain && DBIx::Class::Optional::Dependencies->req_ok_for ('test_leaks_heavy'), + CV_TRACING => !!( + !DBICTest::RunMode->is_plain + && + require DBIx::Class::Optional::Dependencies + && + DBIx::Class::Optional::Dependencies->req_ok_for ('test_leaks_heavy') + ), }; use base 'Exporter'; diff --git a/t/storage/cursor.t b/t/storage/cursor.t index 93a3161..96f917e 100644 --- a/t/storage/cursor.t +++ b/t/storage/cursor.t @@ -6,7 +6,7 @@ use warnings; use Test::More; use Test::Exception; - +use DBIx::Class::Optional::Dependencies; use DBICTest; my $schema = DBICTest->init_schema(cursor_class => 'DBICTest::Cursor'); diff --git a/t/storage/savepoints.t b/t/storage/savepoints.t index 624ee9c..66b7d71 100644 --- a/t/storage/savepoints.t +++ b/t/storage/savepoints.t @@ -5,6 +5,7 @@ use warnings; use Test::More; use Test::Exception; +use DBIx::Class::Optional::Dependencies; use DBIx::Class::_Util qw(modver_gt_or_eq sigwarn_silencer scope_guard);