From: Rafael Kitover Date: Mon, 16 May 2011 14:44:12 +0000 (-0400) Subject: support ->use_namespaces(0) in Loader.pm, fix tests for new dynamic schema behavior X-Git-Tag: 0.07011~117 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=42ea7b88f0aef669a1ce1c169fc097ae48814ffb;p=dbsrgits%2FDBIx-Class-Schema-Loader.git support ->use_namespaces(0) in Loader.pm, fix tests for new dynamic schema behavior --- diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index c01fdbe..d98a3e4 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -164,7 +164,7 @@ sub _invoke_loader { weaken($args->{schema}) if ref $self; $args->{dump_directory} ||= $self->dump_to_dir; $args->{naming} = $self->naming if $self->naming; - $args->{use_namespaces} = $self->use_namespaces if $self->use_namespaces; + $args->{use_namespaces} = $self->use_namespaces if defined $self->use_namespaces; # XXX this only works for relative storage_type, like ::DBI ... my $loader_class = $self->loader_class; diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index a34667d..4430ae0 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -765,7 +765,7 @@ sub _check_back_compat { # just in case, though no one is likely to dump a dynamic schema $self->schema_version_to_dump('0.04006'); - if (not %{ $self->naming }) { + if (not $self->naming_set) { warn <naming('current'); + __PACKAGE__->use_namespaces(0); __PACKAGE__->connection($make_dbictest_db::dsn); __PACKAGE__; }, @@ -40,13 +41,18 @@ my @invocations = ( use base qw/ DBIx::Class::Schema::Loader /; __PACKAGE__->loader_options(); __PACKAGE__->naming('current'); + __PACKAGE__->use_namespaces(0); __PACKAGE__->connect($make_dbictest_db::dsn); }, 'make_schema_at' => sub { use DBIx::Class::Schema::Loader qw/ make_schema_at /; make_schema_at( 'DBICTest::Schema::_make_schema_at', - { really_erase_my_files => 1, naming => 'current' }, + { + really_erase_my_files => 1, + naming => 'current', + use_namespaces => 0 + }, [ $make_dbictest_db::dsn ], ); DBICTest::Schema::_make_schema_at->clone; @@ -55,6 +61,7 @@ my @invocations = ( package DBICTest::Schema::_embedded_options; use base qw/ DBIx::Class::Schema::Loader /; __PACKAGE__->naming('current'); + __PACKAGE__->use_namespaces(0); __PACKAGE__->connect( $make_dbictest_db::dsn, { loader_options => { really_erase_my_files => 1 } } @@ -64,6 +71,7 @@ my @invocations = ( package DBICTest::Schema::_embedded_options_in_attrs; use base qw/ DBIx::Class::Schema::Loader /; __PACKAGE__->naming('current'); + __PACKAGE__->use_namespaces(0); __PACKAGE__->connect( $make_dbictest_db::dsn, undef, @@ -80,7 +88,8 @@ my @invocations = ( $make_dbictest_db::dsn, { loader_options => { really_erase_my_files => 1, - naming => 'current' + naming => 'current', + use_namespaces => 0, } }, ], ); @@ -91,7 +100,8 @@ my @invocations = ( use base qw/ DBIx::Class::Schema::Loader /; __PACKAGE__->loader_options( really_erase_my_files => 1, - naming => 'current' + naming => 'current', + use_namespaces => 0, ); __PACKAGE__->connect( $make_dbictest_db::dsn, @@ -102,7 +112,11 @@ my @invocations = ( use DBIx::Class::Schema::Loader; DBIx::Class::Schema::Loader::make_schema_at( 'DBICTest::Schema::_make_schema_at_explicit', - { really_erase_my_files => 1, naming => 'current' }, + { + really_erase_my_files => 1, + naming => 'current', + use_namespaces => 0, + }, [ $make_dbictest_db::dsn ], ); DBICTest::Schema::_make_schema_at_explicit->clone; @@ -112,7 +126,11 @@ my @invocations = ( use DBIx::Class::Schema::Loader; DBIx::Class::Schema::Loader::make_schema_at( 'DBICTest::Schema::_no_skip_load_external', - { really_erase_my_files => 1, naming => 'current' }, + { + really_erase_my_files => 1, + naming => 'current', + use_namespaces => 0, + }, [ $make_dbictest_db::dsn ], ); DBICTest::Schema::_no_skip_load_external->clone; @@ -122,7 +140,12 @@ my @invocations = ( use DBIx::Class::Schema::Loader; DBIx::Class::Schema::Loader::make_schema_at( 'DBICTest::Schema::_skip_load_external', - { really_erase_my_files => 1, naming => 'current', skip_load_external => 1 }, + { + really_erase_my_files => 1, + naming => 'current', + use_namespaces => 0, + skip_load_external => 1, + }, [ $make_dbictest_db::dsn ], ); DBICTest::Schema::_skip_load_external->clone; @@ -132,6 +155,7 @@ my @invocations = ( package DBICTest::Schema::_use_moose; use base qw/ DBIx::Class::Schema::Loader /; __PACKAGE__->naming('current'); + __PACKAGE__->use_namespaces(0); __PACKAGE__->connect( $make_dbictest_db::dsn, { loader_options => { use_moose => 1 } } diff --git a/t/25backcompat.t b/t/25backcompat.t index 3aec02f..57540f8 100644 --- a/t/25backcompat.t +++ b/t/25backcompat.t @@ -58,7 +58,7 @@ sub class_content_like; Bar => 'Foos', }); - my $res = run_loader(naming => 'current'); + my $res = run_loader(naming => 'current', use_namespaces => 0); my $schema = $res->{schema}; is scalar @{ $res->{warnings} }, 1,