X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema.pm;h=7e60cbf6c4833d3ce32eb4ab5205eabdaf304b90;hb=95787afeb4ecec13279ab2fb26a407c0f971b7df;hp=7040204ed0b66715b29ff28d29cf8eae7d0a8f0f;hpb=3988ce408f0bc7fb0caddebc179a7be0708d26d7;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 7040204..7e60cbf 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -7,9 +7,8 @@ use DBIx::Class::Exception; use Carp::Clan qw/^DBIx::Class/; use Scalar::Util qw/weaken/; use File::Spec; -use MRO::Compat; use Sub::Name (); -require Module::Find; +use Module::Find(); use base qw/DBIx::Class/; @@ -43,7 +42,7 @@ DBIx::Class::Schema - composable schemas $dsn, $user, $password, - { AutoCommit => 0 }, + { AutoCommit => 1 }, ); my $schema2 = Library::Schema->connect($coderef_returning_dbh); @@ -407,12 +406,10 @@ sub load_classes { Set the storage class that will be instantiated when L is called. If the classname starts with C<::>, the prefix C is -assumed by L. +assumed by L. You want to use this to set subclasses of L -in cases where the appropriate subclass is not autodetected, such as -when dealing with MSSQL via L, in which case you'd set it -to C<::DBI::Sybase::MSSQL>. +in cases where the appropriate subclass is not autodetected. If your storage type requires instantiation arguments, those are defined as a second argument in the form of a hashref and the entire @@ -512,7 +509,7 @@ syntax on the C<@connectinfo> argument, or L in general. Note that C expects an arrayref of arguments, but -C does not. C wraps it's arguments in an arrayref +C does not. C wraps its arguments in an arrayref before passing them to C. =head3 Overloading @@ -544,6 +541,8 @@ name. sub resultset { my ($self, $moniker) = @_; + $self->throw_exception('resultset() expects a source name') + unless defined $moniker; return $self->source($moniker)->resultset; } @@ -630,13 +629,13 @@ See L for more information. This interface is preferred over using the individual methods L, L, and L below. -WARNING: If you are connected with C 0> the transaction is +WARNING: If you are connected with C<< AutoCommit => 0 >> the transaction is considered nested, and you will still need to call L to write your -changes when appropriate. You will also want to connect with C -1> to get partial rollback to work, if the storage driver for your database +changes when appropriate. You will also want to connect with C<< auto_savepoint => +1 >> to get partial rollback to work, if the storage driver for your database supports it. -Connecting with C 1> is recommended. +Connecting with C<< AutoCommit => 1 >> is recommended. =cut @@ -756,7 +755,7 @@ i.e., [ 2, 'Indie Band' ], ... ]); - + Since wantarray context is basically the same as looping over $rs->create(...) you won't see any performance benefits and in this case the method is more for convenience. Void context sends the column information directly to storage @@ -807,13 +806,13 @@ Overload C to change the behaviour of C. sub connection { my ($self, @info) = @_; return $self if !@info && $self->storage; - + my ($storage_class, $args) = ref $self->storage_type ? ($self->_normalize_storage_type($self->storage_type),{}) : ($self->storage_type, {}); - + $storage_class = 'DBIx::Class::Storage'.$storage_class if $storage_class =~ m/^::/; - eval "require ${storage_class};"; + eval { $self->ensure_class_loaded ($storage_class) }; $self->throw_exception( "No arguments to load_classes and couldn't load ${storage_class} ($@)" ) if $@; @@ -1125,6 +1124,19 @@ name format is: C<$dir$schema-$version-$type.sql>. You may override this method in your schema if you wish to use a different format. + WARNING + + Prior to DBIx::Class version 0.08100 this method had a different signature: + + my $filename = $table->ddl_filename($type, $dir, $version, $preversion) + + In recent versions variables $dir and $version were reversed in order to + bring the signature in line with other Schema/Storage methods. If you + really need to maintain backward compatibility, you can do the following + in any overriding methods: + + ($dir, $version) = ($version, $dir) if ($DBIx::Class::VERSION < 0.08100); + =cut sub ddl_filename { @@ -1134,7 +1146,7 @@ sub ddl_filename { $filename =~ s/::/-/g; $filename = File::Spec->catfile($dir, "$filename-$version-$type.sql"); $filename =~ s/$version/$preversion-$version/ if($preversion); - + return $filename; } @@ -1360,7 +1372,7 @@ more information. $self->throw_exception ("No arguments to load_classes and couldn't load ${base} ($@)") if $@; - + if ($self eq $target) { # Pathological case, largely caused by the docs on early C::M::DBIC::Plain foreach my $moniker ($self->sources) { @@ -1373,14 +1385,14 @@ more information. $self->connection(@info); return $self; } - + my $schema = $self->compose_namespace($target, $base); { no strict 'refs'; my $name = join '::', $target, 'schema'; *$name = Sub::Name::subname $name, sub { $schema }; } - + $schema->connection(@info); foreach my $moniker ($schema->sources) { my $source = $schema->source($moniker);