From: Rafael Kitover Date: Thu, 14 Jan 2010 03:02:44 +0000 (+0000) Subject: fix for deleting empty Result dir when rewriting result_namespace or downgrading... X-Git-Tag: 0.04999_14~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b5f1b43c116380e8b58b5cba6c870f784bef4a6a;p=dbsrgits%2FDBIx-Class-Schema-Loader.git fix for deleting empty Result dir when rewriting result_namespace or downgrading to load_classes --- diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index 3d293d4..eb8902b 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -958,7 +958,8 @@ sub _dump_to_dir { # remove Result dir if downgrading from use_namespaces, and there are no # files left. - if (my $result_ns = $self->_downgrading_to_load_classes) { + if (my $result_ns = $self->_downgrading_to_load_classes + || $self->_rewriting_result_namespace) { my $result_namespace = $self->_result_namespace( $schema_class, $result_ns, diff --git a/t/25backcompat_v4.t b/t/25backcompat_v4.t index 1d9fe55..8135445 100644 --- a/t/25backcompat_v4.t +++ b/t/25backcompat_v4.t @@ -866,13 +866,14 @@ EOF is $res->{classes}{quuxs}, 'DBIXCSL_Test::Schema::MyResult::Quux', 'using new result_namespace'; + (my $schema_dir = "$DUMP_DIR/$SCHEMA_CLASS") =~ s{::}{/}g; (my $result_dir = "$DUMP_DIR/$SCHEMA_CLASS/MyResult") =~ s{::}{/}g; my $result_count =()= glob "$result_dir/*"; is $result_count, 4, 'correct number of Results after rewritten result_namespace'; - ok ((not -d "$result_dir/Result"), + ok ((not -d "$schema_dir/Result"), 'original Result dir was removed when rewriting result_namespace'); # check that custom content was preserved @@ -900,13 +901,14 @@ EOF is $res->{classes}{quuxs}, 'DBIXCSL_Test::Schema::Mtfnpy::Quux', 'using new result_namespace'; + ($schema_dir = "$DUMP_DIR/$SCHEMA_CLASS") =~ s{::}{/}g; ($result_dir = "$DUMP_DIR/$SCHEMA_CLASS/Mtfnpy") =~ s{::}{/}g; $result_count =()= glob "$result_dir/*"; is $result_count, 4, 'correct number of Results after rewritten result_namespace'; - ok ((not -d "$result_dir/MyResult"), + ok ((not -d "$schema_dir/MyResult"), 'original Result dir was removed when rewriting result_namespace'); # check that custom content was preserved