X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema.pm;h=c6974c112720ee498438655e57c539cd7049c9f7;hb=7ad315356c82a425365b88b6146617485897a4a0;hp=112168266e4cfa62ec256752959fc47f4cf38bb7;hpb=551e711a765052e8bdcb4ab704b5e05c5422330b;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 1121682..c6974c1 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -5,6 +5,7 @@ use warnings; use DBIx::Class::Exception; use Carp::Clan qw/^DBIx::Class/; +use Try::Tiny; use Scalar::Util (); use File::Spec; use Sub::Name (); @@ -82,7 +83,7 @@ particular which module inherits off which. With no arguments, this method uses L to load all your Result classes from a sub-namespace F under your Schema class' -namespace. Eg. With a Schema of I all files in +namespace, i.e. with a Schema of I all files in I are assumed to be Result classes. It also finds all ResultSet classes in the namespace F and @@ -271,6 +272,10 @@ sub load_namespaces { } elsif($rs_class ||= $default_resultset_class) { $class->ensure_class_loaded($rs_class); + if(!$rs_class->isa("DBIx::Class::ResultSet")) { + carp "load_namespaces found ResultSet class $rs_class that does not subclass DBIx::Class::ResultSet"; + } + $class->_ns_get_rsrc_instance ($result_class)->resultset_class($rs_class); } @@ -669,7 +674,7 @@ sub txn_scope_guard { Begins a transaction (does nothing if AutoCommit is off). Equivalent to calling $schema->storage->txn_begin. See -L for more information. +L for more information. =cut @@ -685,7 +690,7 @@ sub txn_begin { =head2 txn_commit Commits the current transaction. Equivalent to calling -$schema->storage->txn_commit. See L +$schema->storage->txn_commit. See L for more information. =cut @@ -703,7 +708,7 @@ sub txn_commit { Rolls back the current transaction. Equivalent to calling $schema->storage->txn_rollback. See -L for more information. +L for more information. =cut @@ -748,7 +753,7 @@ Otherwise, each set of data is inserted into the database using L, and a arrayref of the resulting row objects is returned. -i.e., +e.g. $schema->populate('Artist', [ [ qw/artistid name/ ], @@ -813,10 +818,14 @@ sub connection { $storage_class = 'DBIx::Class::Storage'.$storage_class if $storage_class =~ m/^::/; - eval { $self->ensure_class_loaded ($storage_class) }; - $self->throw_exception( - "No arguments to load_classes and couldn't load ${storage_class} ($@)" - ) if $@; + try { + $self->ensure_class_loaded ($storage_class); + } + catch { + $self->throw_exception( + "No arguments to load_classes and couldn't load ${storage_class} ($_)" + ); + }; my $storage = $storage_class->new($self=>$args); $storage->connect_info(\@info); $self->storage($storage); @@ -851,7 +860,7 @@ attached to the current schema. It also attaches a corresponding L object to the new $schema object. If C<$additional_base_class> is given, the new composed -classes will inherit from first the corresponding classe from the current +classes will inherit from first the corresponding class from the current schema then the base class. For example, for a schema with My::Schema::CD and My::Schema::Artist classes, @@ -927,7 +936,7 @@ sub setup_connection_class { Creates a new savepoint (does nothing outside a transaction). Equivalent to calling $schema->storage->svp_begin. See -L for more information. +L for more information. =cut @@ -944,7 +953,7 @@ sub svp_begin { Releases a savepoint (does nothing outside a transaction). Equivalent to calling $schema->storage->svp_release. See -L for more information. +L for more information. =cut @@ -961,7 +970,7 @@ sub svp_release { Rollback to a savepoint (does nothing outside a transaction). Equivalent to calling $schema->storage->svp_rollback. See -L for more information. +L for more information. =cut @@ -1083,7 +1092,7 @@ sub deployment_statements { $self->storage->deployment_statements($self, @_); } -=head2 create_ddl_dir (EXPERIMENTAL) +=head2 create_ddl_dir =over 4 @@ -1155,7 +1164,7 @@ sub ddl_filename { Provided as the recommended way of thawing schema objects. You can call C directly if you wish, but the thawed objects will not have a -reference to any schema, so are rather useless +reference to any schema, so are rather useless. =cut @@ -1167,8 +1176,8 @@ sub thaw { =head2 freeze -This doesn't actualy do anything more than call L, it is just -provided here for symetry. +This doesn't actually do anything more than call L, it is just +provided here for symmetry. =cut @@ -1269,6 +1278,24 @@ sub register_source { $self->_register_source(@_); } +=head2 unregister_source + +=over 4 + +=item Arguments: $moniker + +=back + +Removes the L from the schema for the given moniker. + +=cut + +sub unregister_source { + my $self = shift; + + $self->_unregister_source(@_); +} + =head2 register_extra_source =over 4 @@ -1378,10 +1405,13 @@ more information. unless ($INC{"DBIx/Class/CDBICompat.pm"} || $warn++); my $base = 'DBIx::Class::ResultSetProxy'; - eval "require ${base};"; - $self->throw_exception - ("No arguments to load_classes and couldn't load ${base} ($@)") - if $@; + try { + eval "require ${base};" + } + catch { + $self->throw_exception + ("No arguments to load_classes and couldn't load ${base} ($_)") + }; if ($self eq $target) { # Pathological case, largely caused by the docs on early C::M::DBIC::Plain