From: Peter Rabbitson Date: Fri, 3 Feb 2012 09:46:06 +0000 (+0100) Subject: Fix complete breakage of ddl_filename on certain paths X-Git-Tag: v0.08197~47 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=aea59b74d807ee65b319f3c1f84709157e12926b Fix complete breakage of ddl_filename on certain paths The careless regex substitution was a poor choice, which became evident when the db file switched to pid-postfixed names. The result was that tests upgrading from v1.0 to 2.0 would completely obliterate a path ending with /2\d0$/ --- diff --git a/Changes b/Changes index b7aef49..57e2ab4 100644 --- a/Changes +++ b/Changes @@ -46,11 +46,13 @@ Revision history for DBIx::Class - Fix leakage of $storage in ::Storage::DBI::Oracle - Fix pessimization of Oracle RowNum limit dialect query when no offset has been specified - - Remove useless vestigial pessimization in Ordered.pm for cases + - Remove useless vestigial pessimization in Ordered.pm for cases when the position column is part of a unique constraint - Fix dbicadmin to no longer ignore the documented 'config' option - The schema-resultsource entanglement is now much more robust under threads + - Fix ::Schema::ddl_filename() failing miserably on paths containing + certain numeric sequences - t/53lean_startup.t adjusted for new 5.15.x base.pm behavior * Misc diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index d36bcf1..dbe4cbe 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -6,7 +6,7 @@ use warnings; use DBIx::Class::Exception; use DBIx::Class::Carp; use Try::Tiny; -use Scalar::Util 'weaken'; +use Scalar::Util qw/weaken blessed/; use Sub::Name 'subname'; use B 'svref_2object'; use DBIx::Class::GlobalDestruction; @@ -1222,12 +1222,12 @@ sub ddl_filename { require File::Spec; - my $filename = ref($self); - $filename =~ s/::/-/g; - $filename = File::Spec->catfile($dir, "$filename-$version-$type.sql"); - $filename =~ s/$version/$preversion-$version/ if($preversion); + $version = "$preversion-$version" if $preversion; - return $filename; + my $class = blessed($self) || $self; + $class =~ s/::/-/g; + + return File::Spec->catfile($dir, "$class-$version-$type.sql"); } =head2 thaw