Revision history for Perl module DBIx::Class::Schema::ResultSetAccessors
+0.03 Mon Jun 13
+ - Now instead of throwing an error and dying when a resultset accessor with the same name exists
+ it simply warns the user.
+
0.01 Wed Jun 8 10:28:25 2011
- original skeleton created with ExtUtils::ModuleMaker::TT
requires 'Sub::Name' => 0;
test_requires 'Test::More' => '0.94';
-test_requires 'Test::Exception';
+test_requires 'Test::Warn';
if ($Module::Install::AUTHOR) {
system("pod2text lib/DBIx/Class/Schema/ResultSetAccessors.pm > README");
use strict;
use warnings;
+use DBIx::Class::Carp qw(carp);
use String::CamelCase;
use Lingua::EN::Inflect::Phrase;
use Sub::Name 'subname';
-our $VERSION = 0.001002;
+our $VERSION = 0.001003;
sub register_source {
my $self = shift;
: $self->resultset_accessor_name($moniker);
if ($schema->can($accessor_name)) {
- $self->throw_exception(
+ carp(
"Can't create ResultSet accessor '$accessor_name'. " .
"Schema method with the same name already exists. " .
"Try overloading the name via resultset_accessor_map."
use lib qw(t/lib);
use Test::More;
-use Test::Exception;
+use Test::Warn;
BEGIN {
use_ok('MyApp1::Schema');
can_ok $schema1, qw/source_resultset/;
isa_ok $schema1->source_resultset, 'DBIx::Class::ResultSet';
-throws_ok {
+# test the warnings
+warning_like { warn_same_name() } qr/Schema method with the same name already exists/,
+ 'Schema method with the same name already exists';
+
+sub warn_same_name {
# must use required, because for some reason throws_ok cannot catch
# erros with "use"
require MyApp2::Schema;
- MyApp2::Schema->connect('dbi:SQLite:dbname=:memory:', '', '');
-} qr/Schema method with the same name already exists/,
- 'Schema method with the same name already exists';
+
+ # eval'ing this, otherwise an odd error is thrown
+ # "Can't call method "_count_select" on an undefined value"
+ # I presume it's due to the store not having the actual schema installed
+ # as we are connecting to an empty database
+ eval {
+ my $schema = MyApp2::Schema->connect('dbi:SQLite:dbname=:memory:', '', '');
+ };
+}
done_testing;