X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader.pm;h=02d3f8e77f8868535f9fe5372d178963e1fcec66;hb=25d38102c55dbe5dc3f9a2e67a4b7538546c7883;hp=89cf56fe471bdcd4e5ad10e45e7ef080b39d9eed;hpb=65e705c303fe8a3bfea7ddb96c4bb97ff2df7c07;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index 89cf56f..02d3f8e 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -10,7 +10,7 @@ use Scalar::Util qw/ weaken /; # Always remember to do all digits for the version even if they're 0 # i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports # brain damage and presumably various other packaging systems too -our $VERSION = '0.04999_12'; +our $VERSION = '0.05001'; __PACKAGE__->mk_group_accessors('inherited', qw/ _loader_args @@ -19,6 +19,7 @@ __PACKAGE__->mk_group_accessors('inherited', qw/ _loader loader_class naming + use_namespaces /); __PACKAGE__->_loader_args({}); @@ -75,11 +76,12 @@ DBIx::Class::Schema::Loader automates the definition of a L by scanning database table definitions and setting up the columns, primary keys, and relationships. -DBIx::Class::Schema::Loader currently supports only the DBI storage type. -It has explicit support for L, L, L, -L, and L. Other DBI drivers may function to -a greater or lesser degree with this loader, depending on how much of the -DBI spec they implement, and how standard their implementation is. +DBIx::Class::Schema::Loader currently supports only the DBI storage type. It +has explicit support for L, L, L, +L, L (for Sybase ASE and MSSSQL), L (for +MSSQL) and L. Other DBI drivers may function to a greater or +lesser degree with this loader, depending on how much of the DBI spec they +implement, and how standard their implementation is. Patches to make other DBDs work correctly welcome. @@ -141,11 +143,45 @@ sub loader_options { my $self = shift; my %args = (ref $_[0] eq 'HASH') ? %{$_[0]} : @_; + $self->_validate_loader_options(\%args); $self->_loader_args(\%args); $self; } +sub _validate_loader_options { + my $self = shift; + my $args = shift; + + my @class_keys = qw( + schema_base_class result_base_class additional_base_classes + left_base_classes additional_classes components resultset_components + ); + foreach my $k ( grep { exists $args->{$_} } @class_keys ) { + my @classes = ref( $args->{$k} ) eq 'ARRAY' ? @{ $args->{$k} } : $args->{$k}; + foreach my $c (@classes) { + + # components default to being under the DBIx::Class namespace unless they + # are preceeded with a '+' + if ( $k =~ m/components$/ && $c !~ s/^\+// ) { + $c = 'DBIx::Class::' . $c; + } + + # 1 == installed, 0 == not installed, undef == invalid classname + my $installed = Class::Inspector->installed($c); + if ( defined($installed) ) { + if ( $installed == 0 ) { + croak qq/$c, as specified in the loader option "$k", is not installed/; + } + } else { + croak qq/$c, as specified in the loader option "$k", is an invalid class name/; + } + } + } + + return; +} + sub _invoke_loader { my $self = shift; my $class = ref $self || $self; @@ -158,6 +194,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; # XXX this only works for relative storage_type, like ::DBI ... my $impl = $self->loader_class @@ -310,6 +347,10 @@ sub import { no strict 'refs'; *{"${cpkg}::naming"} = sub { $self->naming(@_) }; } + elsif($opt eq 'use_namespaces') { + no strict 'refs'; + *{"${cpkg}::use_namespaces"} = sub { $self->use_namespaces(@_) }; + } } } @@ -404,6 +445,25 @@ Can be imported into your dump script and called as a function as well: naming('v4'); +=head2 use_namespaces + +=over 4 + +=item Arguments: 1|0 + +=back + +Controls the use_namespaces options for backward compatibility, see +L for details. + +To upgrade a dynamic schema, use: + + __PACKAGE__->use_namespaces(1); + +Can be imported into your dump script and called as a function as well: + + use_namespaces(1); + =head1 KNOWN ISSUES =head2 Multiple Database Schemas @@ -437,7 +497,7 @@ blblack: Brandon Black =head1 CONTRIBUTORS -ilmarii: Dagfinn Ilmari Mannsåker +ilmari: Dagfinn Ilmari MannsEker arcanez: Justin Hunter @@ -447,14 +507,26 @@ Caelum: Rafael Kitover TSUNODA Kazuya -Robert Bohne +rbo: Robert Bohne -ribasushi: Peter Rabbitson +ribasushi: Peter Rabbitson gugu: Andrey Kostenko jhannah: Jay Hannah +rbuels: Robert Buels + +timbunce: Tim Bunce + +mst: Matt S. Trout + +kane: Jos Boumans + +waawaamilk: Nigel McNie + +acmoore: Andrew Moore + ... and lots of other folks. If we forgot you, please write the current maintainer or RT.