[Bast-commits] r7481 - in DBIx-Class/0.08/trunk: . lib/DBIx
lib/DBIx/Class/Schema lib/DBIx/Class/Storage t
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Wed Sep 2 09:20:25 GMT 2009
Author: ribasushi
Date: 2009-09-02 09:20:25 +0000 (Wed, 02 Sep 2009)
New Revision: 7481
Modified:
DBIx-Class/0.08/trunk/Makefile.PL
DBIx-Class/0.08/trunk/lib/DBIx/Class.pm
DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema/Versioned.pm
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
DBIx-Class/0.08/trunk/t/86sqlt.t
DBIx-Class/0.08/trunk/t/94versioning.t
DBIx-Class/0.08/trunk/t/99dbic_sqlt_parser.t
Log:
Centralize handling of minimum sqlt version to DBIx::Class
Bump version to the latest unborked sqlt (still just a recommend)
Modified: DBIx-Class/0.08/trunk/Makefile.PL
===================================================================
--- DBIx-Class/0.08/trunk/Makefile.PL 2009-09-02 09:07:04 UTC (rev 7480)
+++ DBIx-Class/0.08/trunk/Makefile.PL 2009-09-02 09:20:25 UTC (rev 7481)
@@ -52,7 +52,8 @@
'Hash::Merge', => '0.11',
);
-my $sqlt_recommends = '0.09004';
+# when changing also adjust $DBIx::Class::minimum_sqlt_version
+my $sqlt_recommends = '0.11002';
recommends 'SQL::Translator' => $sqlt_recommends;
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema/Versioned.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema/Versioned.pm 2009-09-02 09:07:04 UTC (rev 7480)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema/Versioned.pm 2009-09-02 09:20:25 UTC (rev 7481)
@@ -520,10 +520,8 @@
return;
}
- eval 'require SQL::Translator "0.09003"';
- if ($@) {
- $self->throw_exception("SQL::Translator 0.09003 required");
- }
+ $self->throw_exception($self->_sqlt_version_error)
+ if (not $self->_sqlt_version_ok);
my $db_tr = SQL::Translator->new({
add_drop_table => 1,
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2009-09-02 09:07:04 UTC (rev 7480)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2009-09-02 09:20:25 UTC (rev 7481)
@@ -2282,9 +2282,8 @@
%{$sqltargs || {}}
};
- $self->throw_exception(q{Can't create a ddl file without SQL::Translator 0.09003: '}
- . $self->_check_sqlt_message . q{'})
- if !$self->_check_sqlt_version;
+ $self->throw_exception("Can't create a ddl file without SQL::Translator: " . $self->_sqlt_version_error)
+ if !$self->_sqlt_version_ok;
my $sqlt = SQL::Translator->new( $sqltargs );
@@ -2426,9 +2425,8 @@
return join('', @rows);
}
- $self->throw_exception(q{Can't deploy without SQL::Translator 0.09003: '}
- . $self->_check_sqlt_message . q{'})
- if !$self->_check_sqlt_version;
+ $self->throw_exception("Can't deploy without either SQL::Translator or a ddl_dir: " . $self->_sqlt_version_error )
+ if !$self->_sqlt_version_ok;
# sources needs to be a parser arg, but for simplicty allow at top level
# coming in
@@ -2515,22 +2513,7 @@
return $type;
}
-{
- my $_check_sqlt_version; # private
- my $_check_sqlt_message; # private
- sub _check_sqlt_version {
- return $_check_sqlt_version if defined $_check_sqlt_version;
- eval 'use SQL::Translator "0.09003"';
- $_check_sqlt_message = $@ || '';
- $_check_sqlt_version = !$@;
- }
- sub _check_sqlt_message {
- _check_sqlt_version if !defined $_check_sqlt_message;
- $_check_sqlt_message;
- }
-}
-
=head2 is_replicating
A boolean that reports if a particular L<DBIx::Class::Storage::DBI> is set to
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class.pm 2009-09-02 09:07:04 UTC (rev 7480)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class.pm 2009-09-02 09:20:25 UTC (rev 7481)
@@ -29,6 +29,10 @@
$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 $sqlt_recommends in Makefile.PL
+my $minimum_sqlt_version = '0.11002';
+
sub MODIFY_CODE_ATTRIBUTES {
my ($class,$code, at attrs) = @_;
$class->mk_classdata('__attr_cache' => {})
@@ -44,6 +48,34 @@
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
Modified: DBIx-Class/0.08/trunk/t/86sqlt.t
===================================================================
--- DBIx-Class/0.08/trunk/t/86sqlt.t 2009-09-02 09:07:04 UTC (rev 7480)
+++ DBIx-Class/0.08/trunk/t/86sqlt.t 2009-09-02 09:20:25 UTC (rev 7481)
@@ -5,8 +5,12 @@
use lib qw(t/lib);
use DBICTest;
-eval "use SQL::Translator";
-plan skip_all => 'SQL::Translator required' if $@;
+BEGIN {
+ require DBIx::Class;
+ plan skip_all =>
+ 'Test needs SQL::Translator ' . DBIx::Class->_sqlt_minimum_version
+ if not DBIx::Class->_sqlt_version_ok;
+}
my $schema = DBICTest->init_schema (no_deploy => 1);
Modified: DBIx-Class/0.08/trunk/t/94versioning.t
===================================================================
--- DBIx-Class/0.08/trunk/t/94versioning.t 2009-09-02 09:07:04 UTC (rev 7480)
+++ DBIx-Class/0.08/trunk/t/94versioning.t 2009-09-02 09:20:25 UTC (rev 7481)
@@ -1,4 +1,5 @@
#!/usr/bin/perl
+
use strict;
use warnings;
use Test::More;
@@ -15,11 +16,10 @@
plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'
unless ($dsn);
-
- eval "use DBD::mysql; use SQL::Translator 0.09003;";
- plan $@
- ? ( skip_all => 'needs DBD::mysql and SQL::Translator 0.09003 for testing' )
- : ( tests => 22 );
+ require DBIx::Class;
+ plan skip_all =>
+ 'Test needs SQL::Translator ' . DBIx::Class->_sqlt_minimum_version
+ if not DBIx::Class->_sqlt_version_ok;
}
my $version_table_name = 'dbix_class_schema_versions';
@@ -182,3 +182,5 @@
unless ($ENV{DBICTEST_KEEP_VERSIONING_DDL}) {
unlink $_ for (values %$fn);
}
+
+done_testing;
Modified: DBIx-Class/0.08/trunk/t/99dbic_sqlt_parser.t
===================================================================
--- DBIx-Class/0.08/trunk/t/99dbic_sqlt_parser.t 2009-09-02 09:07:04 UTC (rev 7480)
+++ DBIx-Class/0.08/trunk/t/99dbic_sqlt_parser.t 2009-09-02 09:20:25 UTC (rev 7481)
@@ -5,12 +5,11 @@
use lib qw(t/lib);
use DBICTest;
-
BEGIN {
- eval "use SQL::Translator 0.09003;";
- if ($@) {
- plan skip_all => 'needs SQL::Translator 0.09003 for testing';
- }
+ require DBIx::Class;
+ plan skip_all =>
+ 'Test needs SQL::Translator ' . DBIx::Class->_sqlt_minimum_version
+ if not DBIx::Class->_sqlt_version_ok;
}
my $schema = DBICTest->init_schema();
@@ -23,8 +22,6 @@
$schema->sources
;
-plan tests => ( @sources * 3);
-
{
my $sqlt_schema = create_schema({ schema => $schema, args => { parser_args => { } } });
@@ -65,6 +62,8 @@
}
}
+done_testing;
+
sub create_schema {
my $args = shift;
More information about the Bast-commits
mailing list