- Fix DB2 foreign-key introspection
- Remove dependency on List::MoreUtils and Sub::Name
- Ensure schema files are generated as binary files on Windows
+ - Fix overwrite_modifications not overwriting if the table hasn't changed
0.07042 2014-08-20
- Fix unescaped left braces in regexes in tests
my $mark_re =
qr{^(# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:)([A-Za-z0-9/+]{22})\r?\n};
- my ($md5, $ts, $ver, $gen);
+ my ($real_md5, $ts, $ver, $gen);
local $_;
while(<$fh>) {
if(/$mark_re/) {
my $pre_md5 = $1;
- $md5 = $2;
+ my $mark_md5 = $2;
# Pull out the version and timestamp from the line above
($ver, $ts) = $gen =~ m/^# Created by DBIx::Class::Schema::Loader( v[\d.]+)?( @ [\d-]+ [\d:]+)?\r?\Z/m;
$ts =~ s/^ @ // if $ts;
$gen .= $pre_md5;
+ $real_md5 = Digest::MD5::md5_base64(encode 'UTF-8', $gen);
croak "Checksum mismatch in '$fn', the auto-generated part of the file has been modified outside of this loader. Aborting.\nIf you want to overwrite these modifications, set the 'overwrite_modifications' loader option.\n"
- if !$self->overwrite_modifications && Digest::MD5::md5_base64(encode 'UTF-8', $gen) ne $md5;
+ if !$self->overwrite_modifications && $real_md5 ne $mark_md5;
last;
}
}
my $custom = do { local $/; <$fh> }
- if $md5;
+ if $real_md5;
$custom ||= '';
$custom =~ s/$CRLF|$LF/\n/g;
close $fh;
- return ($gen, $md5, $ver, $ts, $custom);
+ return ($gen, $real_md5, $ver, $ts, $custom);
}
sub _use {
use strict;
-use Test::More tests => 5;
+use Test::More;
use Test::Exception;
use Test::Warn;
use lib qw(t/lib);
use File::Temp qw/ tempdir tempfile /;
use DBIx::Class::Schema::Loader;
+use DBIx::Class::Schema::Loader::Utils qw/ slurp_file /;
my $tempdir = tempdir( CLEANUP => 1 );
my $foopm = File::Spec->catfile( $tempdir,
dump_schema( overwrite_modifications => 1 );
} 'does not throw when dumping with overwrite_modifications';
+
+unlike slurp_file $foopm, qr/"somethingelse"/, "Modifications actually overwritten";
+
sub dump_schema {
# need to poke _loader_invoked in order to be able to rerun the
);
} [qr/^Dumping manual schema/, qr/^Schema dump completed/ ];
}
+
+done_testing();