support ->use_namespaces(0) in Loader.pm, fix tests for new dynamic schema behavior
Rafael Kitover [Mon, 16 May 2011 14:44:12 +0000 (10:44 -0400)]
lib/DBIx/Class/Schema/Loader.pm
lib/DBIx/Class/Schema/Loader/Base.pm
t/20invocations.t
t/25backcompat.t

index c01fdbe..d98a3e4 100644 (file)
@@ -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;
index a34667d..4430ae0 100644 (file)
@@ -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 <<EOF unless $ENV{SCHEMA_LOADER_BACKCOMPAT};
 
 Dynamic schema detected, will run in 0.04006 mode.
index 51332f8..059eda1 100644 (file)
@@ -32,6 +32,7 @@ my @invocations = (
         package DBICTest::Schema::_hardcode;
         use base qw/ DBIx::Class::Schema::Loader /;
         __PACKAGE__->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 } }
index 3aec02f..57540f8 100644 (file)
@@ -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,