From: Peter Rabbitson Date: Fri, 18 Sep 2009 18:09:04 +0000 (+0000) Subject: This code belogs in Storage::DBI X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b2b2e7fddfd45a365a5cab9c7c9371b1c2557741;p=dbsrgits%2FDBIx-Class-Historic.git This code belogs in Storage::DBI --- diff --git a/Makefile.PL b/Makefile.PL index d2884c1..8c1e88b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -62,7 +62,7 @@ my %replication_requires = ( my %force_requires_if_author = ( %replication_requires, - # when changing also adjust $DBIx::Class::minimum_sqlt_version + # when changing also adjust $DBIx::Class::Storage::DBI::minimum_sqlt_version 'SQL::Translator' => '0.11002', # 'Module::Install::Pod::Inherit' => '0.01', diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index a2c7ce2..d777873 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -24,15 +24,10 @@ sub component_base_class { 'DBIx::Class' } # Always remember to do all digits for the version even if they're 0 # i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports # brain damage and presumably various other packaging systems too - $VERSION = '0.08111'; $VERSION = eval $VERSION; # numify for warning-free dev releases -# what version of sqlt do we require if deploy() without a ddl_dir is invoked -# when changing also adjust the corresponding author_require in Makefile.PL -my $minimum_sqlt_version = '0.11002'; - sub MODIFY_CODE_ATTRIBUTES { my ($class,$code,@attrs) = @_; $class->mk_classdata('__attr_cache' => {}) @@ -48,34 +43,6 @@ sub _attr_cache { return $@ ? $cache : { %$cache, %$rest }; } -# SQLT version handling -{ - my $_sqlt_version_ok; # private - my $_sqlt_version_error; # private - - sub _sqlt_version_ok { - if (!defined $_sqlt_version_ok) { - eval "use SQL::Translator $minimum_sqlt_version"; - if ($@) { - $_sqlt_version_ok = 0; - $_sqlt_version_error = $@; - } - else { - $_sqlt_version_ok = 1; - } - } - return $_sqlt_version_ok; - } - - sub _sqlt_version_error { - shift->_sqlt_version_ok unless defined $_sqlt_version_ok; - return $_sqlt_version_error; - } - - sub _sqlt_minimum_version { $minimum_sqlt_version }; -} - - 1; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index 50cae7e..3e7f517 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -520,11 +520,11 @@ sub _create_db_to_schema_diff { return; } - $self->throw_exception($self->_sqlt_version_error) - if (not $self->_sqlt_version_ok); + $self->throw_exception($self->storage->_sqlt_version_error) + if (not $self->storage->_sqlt_version_ok); - my $db_tr = SQL::Translator->new({ - add_drop_table => 1, + my $db_tr = SQL::Translator->new({ + add_drop_table => 1, parser => 'DBI', parser_args => { dbh => $self->storage->dbh } }); diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index e33b77f..3fd4f7c 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -14,6 +14,11 @@ use DBIx::Class::Storage::Statistics; use Scalar::Util(); use List::Util(); +# what version of sqlt do we require if deploy() without a ddl_dir is invoked +# when changing also adjust the corresponding author_require in Makefile.PL +my $minimum_sqlt_version = '0.11002'; + + __PACKAGE__->mk_group_accessors('simple' => qw/_connect_info _dbi_connect_info _dbh _sql_maker _sql_maker_opts _conn_pid _conn_tid transaction_depth _dbh_autocommit _driver_determined savepoints/ @@ -2618,6 +2623,33 @@ sub lag_behind_master { return; } +# SQLT version handling +{ + my $_sqlt_version_ok; # private + my $_sqlt_version_error; # private + + sub _sqlt_version_ok { + if (!defined $_sqlt_version_ok) { + eval "use SQL::Translator $minimum_sqlt_version"; + if ($@) { + $_sqlt_version_ok = 0; + $_sqlt_version_error = $@; + } + else { + $_sqlt_version_ok = 1; + } + } + return $_sqlt_version_ok; + } + + sub _sqlt_version_error { + shift->_sqlt_version_ok unless defined $_sqlt_version_ok; + return $_sqlt_version_error; + } + + sub _sqlt_minimum_version { $minimum_sqlt_version }; +} + sub DESTROY { my $self = shift; diff --git a/t/86sqlt.t b/t/86sqlt.t index 1962431..4327cef 100644 --- a/t/86sqlt.t +++ b/t/86sqlt.t @@ -6,10 +6,10 @@ use lib qw(t/lib); use DBICTest; BEGIN { - require DBIx::Class; + require DBIx::Class::Storage::DBI; plan skip_all => - 'Test needs SQL::Translator ' . DBIx::Class->_sqlt_minimum_version - if not DBIx::Class->_sqlt_version_ok; + 'Test needs SQL::Translator ' . DBIx::Class::Storage::DBI->_sqlt_minimum_version + if not DBIx::Class::Storage::DBI->_sqlt_version_ok; } my $schema = DBICTest->init_schema (no_deploy => 1); diff --git a/t/94versioning.t b/t/94versioning.t index 9ea6762..03a61d3 100644 --- a/t/94versioning.t +++ b/t/94versioning.t @@ -16,10 +16,10 @@ BEGIN { plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test' unless ($dsn); - require DBIx::Class; + require DBIx::Class::Storage::DBI; plan skip_all => - 'Test needs SQL::Translator ' . DBIx::Class->_sqlt_minimum_version - if not DBIx::Class->_sqlt_version_ok; + 'Test needs SQL::Translator ' . DBIx::Class::Storage::DBI->_sqlt_minimum_version + if not DBIx::Class::Storage::DBI->_sqlt_version_ok; } my $version_table_name = 'dbix_class_schema_versions'; diff --git a/t/99dbic_sqlt_parser.t b/t/99dbic_sqlt_parser.t index 6f3a3e2..d4b1a9f 100644 --- a/t/99dbic_sqlt_parser.t +++ b/t/99dbic_sqlt_parser.t @@ -6,10 +6,10 @@ use lib qw(t/lib); use DBICTest; BEGIN { - require DBIx::Class; + require DBIx::Class::Storage::DBI; plan skip_all => - 'Test needs SQL::Translator ' . DBIx::Class->_sqlt_minimum_version - if not DBIx::Class->_sqlt_version_ok; + 'Test needs SQL::Translator ' . DBIx::Class::Storage::DBI->_sqlt_minimum_version + if not DBIx::Class::Storage::DBI->_sqlt_version_ok; } my $schema = DBICTest->init_schema();