[Bast-commits] r3474 - in branches/DBIx-Class-current: .
lib/DBIx/Class/Storage t
blblack at dev.catalyst.perl.org
blblack at dev.catalyst.perl.org
Tue Jun 5 12:07:34 GMT 2007
Author: blblack
Date: 2007-06-05 12:07:34 +0100 (Tue, 05 Jun 2007)
New Revision: 3474
Modified:
branches/DBIx-Class-current/Changes
branches/DBIx-Class-current/lib/DBIx/Class/Storage/DBI.pm
branches/DBIx-Class-current/t/94versioning.t
Log:
Fixed up SQLT test/runtime deps
Modified: branches/DBIx-Class-current/Changes
===================================================================
--- branches/DBIx-Class-current/Changes 2007-06-04 15:33:54 UTC (rev 3473)
+++ branches/DBIx-Class-current/Changes 2007-06-05 11:07:34 UTC (rev 3474)
@@ -1,5 +1,6 @@
Revision history for DBIx::Class
+ - Fixed up SQL::Translator test/runtime dependencies
- Fixed t/60core.t in the absence of DateTime::Format::MySQL
0.07999_04 2007-06-01 14:04:00
Modified: branches/DBIx-Class-current/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- branches/DBIx-Class-current/lib/DBIx/Class/Storage/DBI.pm 2007-06-04 15:33:54 UTC (rev 3473)
+++ branches/DBIx-Class-current/lib/DBIx/Class/Storage/DBI.pm 2007-06-05 11:07:34 UTC (rev 3474)
@@ -1231,8 +1231,9 @@
$version ||= $schema->VERSION || '1.x';
$sqltargs = { ( add_drop_table => 1 ), %{$sqltargs || {}} };
- eval "use SQL::Translator";
- $self->throw_exception("Can't create a ddl file without SQL::Translator: $@") if $@;
+ $self->throw_exception(q{Can't create a ddl file without SQL::Translator 0.08: '}
+ . $self->_check_sqlt_message . q{'})
+ if !$self->_check_sqlt_version;
my $sqlt = SQL::Translator->new({
# debug => 1,
@@ -1271,12 +1272,7 @@
if($preversion)
{
- eval "use SQL::Translator::Diff";
- if($@)
- {
- warn("Can't diff versions without SQL::Translator::Diff: $@");
- next;
- }
+ require SQL::Translator::Diff;
my $prefilename = $schema->ddl_filename($db, $dir, $preversion);
# print "Previous version $prefilename\n";
@@ -1385,25 +1381,23 @@
return join('', @rows);
}
- eval "use SQL::Translator";
- if(!$@)
- {
- eval "use SQL::Translator::Parser::DBIx::Class;";
- $self->throw_exception($@) if $@;
- eval "use SQL::Translator::Producer::${type};";
- $self->throw_exception($@) if $@;
+ $self->throw_exception(q{Can't deploy without SQL::Translator 0.08: '}
+ . $self->_check_sqlt_message . q{'})
+ if !$self->_check_sqlt_version;
- # sources needs to be a parser arg, but for simplicty allow at top level
- # coming in
- $sqltargs->{parser_args}{sources} = delete $sqltargs->{sources}
- if exists $sqltargs->{sources};
+ require SQL::Translator::Parser::DBIx::Class;
+ eval qq{use SQL::Translator::Producer::${type}};
+ $self->throw_exception($@) if $@;
- my $tr = SQL::Translator->new(%$sqltargs);
- SQL::Translator::Parser::DBIx::Class::parse( $tr, $schema );
- return "SQL::Translator::Producer::${type}"->can('produce')->($tr);
- }
+ # sources needs to be a parser arg, but for simplicty allow at top level
+ # coming in
+ $sqltargs->{parser_args}{sources} = delete $sqltargs->{sources}
+ if exists $sqltargs->{sources};
- $self->throw_exception("No SQL::Translator, and no Schema file found, aborting deploy");
+ my $tr = SQL::Translator->new(%$sqltargs);
+ SQL::Translator::Parser::DBIx::Class::parse( $tr, $schema );
+ return "SQL::Translator::Producer::${type}"->can('produce')->($tr);
+
return;
}
@@ -1459,6 +1453,22 @@
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.08';
+ $_check_sqlt_message = $@ ? $@ : '';
+ $_check_sqlt_version = $@ ? 0 : 1;
+ }
+
+ sub _check_sqlt_message {
+ _check_sqlt_version if !defined $_check_sqlt_message;
+ $_check_sqlt_message;
+ }
+}
+
sub DESTROY {
my $self = shift;
return if !$self->_dbh;
Modified: branches/DBIx-Class-current/t/94versioning.t
===================================================================
--- branches/DBIx-Class-current/t/94versioning.t 2007-06-04 15:33:54 UTC (rev 3473)
+++ branches/DBIx-Class-current/t/94versioning.t 2007-06-05 11:07:34 UTC (rev 3474)
@@ -5,9 +5,9 @@
use File::Spec;
BEGIN {
- eval "use DBD::SQLite; use SQL::Translator;";
+ eval "use DBD::SQLite; use SQL::Translator 0.08;";
plan $@
- ? ( skip_all => 'needs DBD::SQLite and SQL::Translator for testing' )
+ ? ( skip_all => 'needs DBD::SQLite and SQL::Translator 0.08 for testing' )
: ( tests => 6 );
}
More information about the Bast-commits
mailing list