fix silly bug
Arthur Axel 'fREW' Schmidt [Thu, 15 Jul 2010 02:26:58 +0000 (21:26 -0500)]
Changes
lib/DBIx/Class/DeploymentHandler.pm
lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm
t/bugs/01-emailed-bug-01.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index b2862c7..82f85f7 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
 Revision history for {{$dist->name}}
 
 {{$NEXT}}
+       - fix bug caused by install_version_storage not passing a required param
        - add force_overwrite attribute to SQLTDM
 
 0.001002  2010-07-07 21:11:45 CST6CDT
index 376138d..a29af6f 100644 (file)
@@ -39,8 +39,11 @@ sub prepare_version_storage_install {
 sub install_version_storage {
   my $self = shift;
 
+  my $version = (shift||{})->{version} || $self->schema_version;
+
   $self->install_resultsource({
-    result_source => $self->version_storage->version_rs->result_source
+    result_source => $self->version_storage->version_rs->result_source,
+    version       => $version,
   });
 }
 
index 92fb92d..45ad608 100644 (file)
@@ -493,8 +493,10 @@ sub _resultsource_protoschema_filename {
 
 sub install_resultsource {
   my ($self, $args) = @_;
-  my $source          = $args->{result_source};
-  my $version         = $args->{version};
+  my $source          = $args->{result_source}
+    or die 'result_source must be passed to install_resultsource';
+  my $version         = $args->{version}
+    or die 'version must be passed to install_resultsource';
   log_info { 'installing_resultsource ' . $source->source_name . ", version $version" };
   my $rs_install_file =
     $self->_resultsource_install_filename($source->source_name);
diff --git a/t/bugs/01-emailed-bug-01.t b/t/bugs/01-emailed-bug-01.t
new file mode 100644 (file)
index 0000000..1303f04
--- /dev/null
@@ -0,0 +1,44 @@
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use DBICDHTest;
+use DBIx::Class::DeploymentHandler;
+use aliased 'DBIx::Class::DeploymentHandler', 'DH';
+
+use File::Path 'remove_tree';
+use Test::More;
+use Test::Exception;
+
+DBICDHTest::ready;
+
+my $dbh = DBI->connect('dbi:SQLite::memory:');
+my @connection = (sub { $dbh }, { ignore_version => 1 });
+my $sql_dir = 't/sql';
+
+use_ok 'DBICVersion_v1';
+my $s = DBICVersion::Schema->connect(@connection);
+$DBICVersion::Schema::VERSION = 1;
+ok($s, 'DBICVersion::Schema 1 instantiates correctly');
+
+my $dh = DH->new({
+  script_directory => $sql_dir,
+  schema => $s,
+  databases => 'SQLite',
+  sql_translator_args => { add_drop_table => 0 },
+});
+
+ok($dh, 'DBIx::Class::DeploymentHandler w/1 instantiates correctly');
+$dh->prepare_version_storage_install;
+
+
+dies_ok { $s->resultset('__VERSION')->first->version } 'version_storage not installed';
+$dh->install_version_storage;
+
+$dh->add_database_version( { version => $s->schema_version } );
+
+lives_ok { $s->resultset('__VERSION')->first->version } 'version_storage installed';
+
+done_testing;