Subject: | bug report of DBIx::Migration |
Date: | Fri, 25 Apr 2008 12:53:53 +0900 |
To: | <bug-DBIx-Migration [...] rt.cpan.org> |
From: | "HIRAYAMA, Takayuki" <hirayama [...] fractalist.jp> |
Hello.
= Environment Info:
* Distribution name and version: DBIx::Migration-0.0.5
* Perl version: 5.8.5
* Operating System vendor and version: Linux 2.6.9-55.ELsmp #1 SMP Wed
May 2 14:28:44 EDT 2007 i686 athlon i386 GNU/Linux
I found bug in DBIx::Migration.
It is so useful, but not works for migrate directory containing sql
files over 10 files
because code in sub _files describes:
sub _files {
my ( $self, $type, $need ) = @_;
my @files;
for my $i (@$need) {
opendir(DIR, $self->dir) or die $!;
while (my $file = readdir(DIR)) {
next unless $file =~ /${i}_$type\.sql$/;
$file = File::Spec->catdir($self->dir, $file);
push @files, { name => $file, version => $i };
}
closedir(DIR);
}
return undef unless @$need == @files;
return @files ? \@files : undef;
}
If xxx_1.sql and xxx_11.sql are included for the directory, both files
are pushed to @files
and undef returned because @$need does not match @files.
I made and tried the following patch, and behaved correctly.
--- Migration.pm.bak 2008-04-25 12:24:53.000000000 +0900
+++ Migration.pm 2008-04-25 12:25:46.000000000 +0900
@@ -190,7 +190,7 @@
for my $i (@$need) {
opendir(DIR, $self->dir) or die $!;
while (my $file = readdir(DIR)) {
- next unless $file =~ /${i}_$type\.sql$/;
+ next unless $file =~ /(^|\D)${i}_$type\.sql$/;
$file = File::Spec->catdir($self->dir, $file);
push @files, { name => $file, version => $i };
}
Sorry for my poor English:-)
Regars,