From: Brandon Black Date: Tue, 24 Jan 2006 10:29:35 +0000 (+0000) Subject: get rid of now-useless namespace option X-Git-Tag: 0.03000~46 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=38348090d25c45a95d32d640de77367a6a0284ea;p=dbsrgits%2FDBIx-Class-Schema-Loader.git get rid of now-useless namespace option --- diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index 5dfde5c..51b2792 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -25,7 +25,6 @@ DBIx::Class::Schema::Loader - Dynamic definition of a DBIx::Class::Schema dsn => "dbi:mysql:dbname", user => "root", password => "", - namespace => "My", additional_classes => [qw/DBIx::Class::Foo/], additional_base_classes => [qw/My::Stuff/], left_base_classes => [qw/DBIx::Class::Bar/], @@ -76,9 +75,6 @@ sub load_from_connection { die qq/dsn argument is required/ if ! $args{dsn}; - $args{namespace} ||= $class; - $args{namespace} =~ s/(.*)::$/$1/; - my $dsn = $args{dsn}; my ($driver) = $dsn =~ m/^dbi:(\w*?)(?:\((.*?)\))?:/i; $driver = 'SQLite' if $driver eq 'SQLite2'; diff --git a/lib/DBIx/Class/Schema/Loader/DB2.pm b/lib/DBIx/Class/Schema/Loader/DB2.pm index d0859a9..8a3670e 100644 --- a/lib/DBIx/Class/Schema/Loader/DB2.pm +++ b/lib/DBIx/Class/Schema/Loader/DB2.pm @@ -14,12 +14,11 @@ DBIx::Class::Schema::Loader::DB2 - DBIx::Class::Schema::Loader DB2 Implementatio # $loader is a DBIx::Class::Schema::Loader::DB2 my $loader = DBIx::Class::Schema::Loader->new( - dsn => "dbi:DB2:dbname", - user => "myuser", - password => "", - namespace => "Data", - schema => "MYSCHEMA", - dropschema => 0, + dsn => "dbi:DB2:dbname", + user => "myuser", + password => "", + db_schema => "MYSCHEMA", + drop_schema => 1, ); =head1 DESCRIPTION diff --git a/lib/DBIx/Class/Schema/Loader/Generic.pm b/lib/DBIx/Class/Schema/Loader/Generic.pm index 896e2fe..01e0525 100644 --- a/lib/DBIx/Class/Schema/Loader/Generic.pm +++ b/lib/DBIx/Class/Schema/Loader/Generic.pm @@ -54,10 +54,6 @@ Enable debug messages. DBI Data Source Name. -=head3 namespace - -Namespace under which your table classes will be initialized. - =head3 password Password. @@ -102,7 +98,6 @@ sub _load_from_connection { $class->loader_data({ _datasource => [ $args{dsn}, $args{user}, $args{password}, $args{options} ], - _namespace => $args{namespace}, _additional => $additional, _additional_base => $additional_base, _left_base => $left_base, @@ -222,8 +217,6 @@ sub _belongs_to_many { sub _load_classes { my $class = shift; - my $namespace = $class->loader_data->{_namespace}; - my @tables = $class->_tables(); my @db_classes = $class->_db_classes(); my $additional = join '', map "use $_;\n", @{ $class->loader_data->{_additional} }; @@ -244,7 +237,7 @@ sub _load_classes { } my $table_subclass = $class->_table2subclass($db_schema, $tbl); - my $table_class = "$namespace\::$table_subclass"; + my $table_class = "$class\::$table_subclass"; $class->inject_base( $table_class, 'DBIx::Class::Core' ); $_->require for @db_classes; diff --git a/lib/DBIx/Class/Schema/Loader/Pg.pm b/lib/DBIx/Class/Schema/Loader/Pg.pm index 04e67f1..791ff81 100644 --- a/lib/DBIx/Class/Schema/Loader/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/Pg.pm @@ -17,7 +17,6 @@ DBIx::Class::Schema::Loader::Pg - DBIx::Class::Schema::Loader Postgres Implement dsn => "dbi:Pg:dbname=dbname", user => "postgres", password => "", - namespace => "Data", ); =head1 DESCRIPTION diff --git a/lib/DBIx/Class/Schema/Loader/SQLite.pm b/lib/DBIx/Class/Schema/Loader/SQLite.pm index 1a860ac..8983712 100644 --- a/lib/DBIx/Class/Schema/Loader/SQLite.pm +++ b/lib/DBIx/Class/Schema/Loader/SQLite.pm @@ -16,7 +16,6 @@ DBIx::Class::Schema::Loader::SQLite - DBIx::Class::Schema::Loader SQLite Impleme # $loader is a DBIx::Class::Schema::Loader::SQLite my $loader = DBIx::Class::Schema::Loader->new( dsn => "dbi:SQLite:dbname=/path/to/dbfile", - namespace => "Data", ); =head1 DESCRIPTION diff --git a/lib/DBIx/Class/Schema/Loader/mysql.pm b/lib/DBIx/Class/Schema/Loader/mysql.pm index 8c941f8..a203eff 100644 --- a/lib/DBIx/Class/Schema/Loader/mysql.pm +++ b/lib/DBIx/Class/Schema/Loader/mysql.pm @@ -17,7 +17,6 @@ DBIx::Class::Schema::Loader::mysql - DBIx::Schema::Class::Loader mysql Implement dsn => "dbi:mysql:dbname", user => "root", password => "", - namespace => "Data", ); =head1 DESCRIPTION diff --git a/t/dbixcsl_common_tests.pm b/t/dbixcsl_common_tests.pm index b56eb82..b9c5624 100644 --- a/t/dbixcsl_common_tests.pm +++ b/t/dbixcsl_common_tests.pm @@ -40,17 +40,14 @@ sub run_tests { $self->create(); - my $namespace = 'DBIXCSL_Test_' . $self->{vendor}; + my $schema_class = 'DBIXCSL_Test_' . $self->{vendor} . '::Schema'; my $debug = ($self->{verbose} > 1) ? 1 : 0; - my $schema_pkg = "$namespace\::Schema"; - my %loader_opts = ( dsn => $self->{dsn}, user => $self->{user}, password => $self->{password}, - namespace => $namespace, constraint => '^(?:\S+\.)?(?i:loader_test)[0-9]+$', relationships => 1, debug => $debug, @@ -60,14 +57,14 @@ sub run_tests { $loader_opts{drop_db_schema} = $self->{drop_db_schema} if $self->{drop_db_schema}; eval qq{ - package $schema_pkg; + package $schema_class; use base qw/DBIx::Class::Schema::Loader/; __PACKAGE__->load_from_connection(\%loader_opts); }; ok(!$@, "Loader initialization failed: $@"); - my $conn = $schema_pkg->connect($self->{dsn},$self->{user},$self->{password}); + my $conn = $schema_class->connect($self->{dsn},$self->{user},$self->{password}); my $moniker1 = $conn->moniker('loader_test1'); my $rsobj1 = $conn->resultset($moniker1); @@ -113,7 +110,7 @@ sub run_tests { # basic rel test my $obj4 = $rsobj4->find(123); - isa_ok( $obj4->fkid, "$namespace\::$moniker3"); + isa_ok( $obj4->fkid, "$schema_class\::$moniker3"); # fk def in comments should not be parsed my $obj5 = $rsobj5->find( id1 => 1, id2 => 1 ); @@ -121,7 +118,7 @@ sub run_tests { # mulit-col fk def (works for some, not others...) my $obj6 = $rsobj6->find(1); - isa_ok( $obj6->loader_test2, "$namespace\::$moniker2" ); + isa_ok( $obj6->loader_test2, "$schema_class\::$moniker2" ); SKIP: { skip "Multi-column FKs are only half-working for this vendor", 1 unless $self->{multi_fk_broken}; @@ -130,7 +127,7 @@ sub run_tests { # fk that references a non-pk key (UNIQUE) my $obj8 = $rsobj8->find(1); - isa_ok( $obj8->loader_test7, "$namespace\::$moniker7" ); + isa_ok( $obj8->loader_test7, "$schema_class\::$moniker7" ); # from Chisel's tests... SKIP: { @@ -171,7 +168,7 @@ sub run_tests { 'One $rsobj10 returned from search' ); my $obj10_3 = $results->first(); - isa_ok( $obj10_3, "$namespace\::$moniker10" ); + isa_ok( $obj10_3, "$schema_class\::$moniker10" ); is( $obj10_3->loader_test11()->id(), $obj11->id(), 'found same $rsobj11 object we expected' ); }