From: André Walker Date: Thu, 6 Sep 2012 02:43:07 +0000 (-0300) Subject: allow user to set qualify_objects to false X-Git-Tag: 0.07030~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9890b10ce0d06d1f4ba1ded6cdb7e130768bf487;p=dbsrgits%2FDBIx-Class-Schema-Loader.git allow user to set qualify_objects to false The qualify_objects attribute in the DBIx::Class::Schema::Loader::Base was automatically set to true when there were multiple db_schema's, even if the user explicitly set it to false. This changes that behaviour, allowing more flexibility on prefixing the names. --- diff --git a/Changes b/Changes index eff7ca2..65a4ce6 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - allow user to set qualify_objects=0 in multischema configurations + 0.07029 2012-09-05 16:41:56 - Oracle: introspect ON DELETE and DEFERRABLE FK clauses - Oracle WARNING: on_delete is now 'NO ACTION' by default, not diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index eae97d3..2444d73 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -669,6 +669,8 @@ alnewkirk: Al Newkirk angelixd: Paul C. Mantz +andrewalker: André Walker + ... and lots of other folks. If we forgot you, please write the current maintainer or RT. diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index af194a4..ee67a54 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -747,7 +747,8 @@ L = C or greater is required with this option. Set to true to prepend the L to table names for C<< __PACKAGE__->table >> calls, and to some other things like Oracle sequences. -This attribute is automatically set to true for multi db_schema configurations. +This attribute is automatically set to true for multi db_schema configurations, +unless explicitly set to false by the user. =head2 use_moose @@ -1052,7 +1053,7 @@ sub new { if (defined $self->db_schema) { if (ref $self->db_schema eq 'ARRAY') { - if (@{ $self->db_schema } > 1) { + if (@{ $self->db_schema } > 1 && not defined $self->{qualify_objects}) { $self->{qualify_objects} = 1; } elsif (@{ $self->db_schema } == 0) { @@ -1060,7 +1061,7 @@ sub new { } } elsif (not ref $self->db_schema) { - if ($self->db_schema eq '%') { + if ($self->db_schema eq '%' && not defined $self->{qualify_objects}) { $self->{qualify_objects} = 1; } diff --git a/t/23dumpmore.t b/t/23dumpmore.t index 0b17dea..0ca9461 100644 --- a/t/23dumpmore.t +++ b/t/23dumpmore.t @@ -305,6 +305,29 @@ $t->dump_test( }, ); +# test qualify_objects +$t->dump_test( + classname => 'DBICTest::DumpMore::1', + options => { + db_schema => [ 'foo_schema', 'bar_schema' ], + qualify_objects => 0, + use_namespaces => 1, + }, + warnings => [ + qr/^db_schema is not supported on SQLite/, + ], + regexes => { + 'Result/Foo' => [ + # the table name should not include the db schema + qr/^\Q__PACKAGE__->table("foo");\E/m, + ], + 'Result/Bar' => [ + # the table name should not include the db schema + qr/^\Q__PACKAGE__->table("bar");\E/m, + ], + }, +); + # test moniker_parts $t->dump_test( classname => 'DBICTest::DumpMore::1',