use strict;
use warnings;
-use DBIx::Class::Exception;
+use base 'DBIx::Class';
+
use DBIx::Class::Carp;
use Try::Tiny;
use Scalar::Util qw/weaken blessed/;
use Devel::GlobalDestruction;
use namespace::clean;
-use base qw/DBIx::Class/;
-
__PACKAGE__->mk_classdata('class_mappings' => {});
__PACKAGE__->mk_classdata('source_registrations' => {});
__PACKAGE__->mk_classdata('storage_type' => '::DBI');
=back
+ package MyApp::Schema;
__PACKAGE__->load_namespaces();
__PACKAGE__->load_namespaces(
result_namespace => 'Res',
resultset_namespace => 'RSet',
- default_resultset_class => '+MyDB::Othernamespace::RSet',
+ default_resultset_class => '+MyApp::Othernamespace::RSet',
);
With no arguments, this method uses L<Module::Find> to load all of the
=cut
sub class {
- my ($self, $source_name) = @_;
- return $self->source($source_name)->result_class;
+ return shift->source(shift)->result_class;
}
=head2 txn_do
sub populate {
my ($self, $name, $data) = @_;
- if(my $rs = $self->resultset($name)) {
- if(defined wantarray) {
- return $rs->populate($data);
- } else {
- $rs->populate($data);
- }
- } else {
- $self->throw_exception("$name is not a resultset");
- }
+ my $rs = $self->resultset($name)
+ or $self->throw_exception("'$name' is not a resultset");
+
+ return $rs->populate($data);
}
=head2 connection
=item Arguments: $target_namespace, $additional_base_class?
-=item Retur Value: $new_schema
+=item Return Value: $new_schema
=back
Clones the schema and its associated result_source objects and returns the
copy. The resulting copy will have the same attributes as the source schema,
-except for those attributes explicitly overriden by the provided C<%attrs>.
+except for those attributes explicitly overridden by the provided C<%attrs>.
=cut
=cut
-my $false_exception_action_warned;
sub throw_exception {
my $self = shift;
." (original error: $_[0])"
);
}
- elsif(! $false_exception_action_warned++) {
- carp (
- "The exception_action handler installed on $self returned false instead"
- .' of throwing an exception. This behavior has been deprecated, adjust your'
- .' handler to always rethrow the supplied error.'
- );
- }
+
+ carp_unique (
+ "The exception_action handler installed on $self returned false instead"
+ .' of throwing an exception. This behavior has been deprecated, adjust your'
+ .' handler to always rethrow the supplied error.'
+ );
}
DBIx::Class::Exception->throw($_[0], $self->stacktrace);
See L<SQL::Translator/METHODS> for a list of values for C<\%sqlt_args>.
The most common value for this would be C<< { add_drop_table => 1 } >>
to have the SQL produced include a C<DROP TABLE> statement for each table
-created. For quoting purposes supply C<quote_table_names> and
-C<quote_field_names>.
+created. For quoting purposes supply C<quote_identifiers>.
Additionally, the DBIx::Class parser accepts a C<sources> parameter as a hash
ref or an array ref, containing a list of source to deploy. If present, then