[Catalyst-commits] r9996 - in trunk/Catalyst-Model-DBIC-Schema: . lib/Catalyst/Model/DBIC lib/Catalyst/Model/DBIC/Schema lib/Catalyst/Model/DBIC/Schema/Role

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Sun May 3 19:13:11 GMT 2009


Author: caelum
Date: 2009-05-03 19:13:06 +0000 (Sun, 03 May 2009)
New Revision: 9996

Modified:
   trunk/Catalyst-Model-DBIC-Schema/Changes
   trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm
   trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Caching.pm
   trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Replicated.pm
   trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm
Log:
C::M::DBIC::Schema - warn on empty schema

Modified: trunk/Catalyst-Model-DBIC-Schema/Changes
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/Changes	2009-05-03 18:57:13 UTC (rev 9995)
+++ trunk/Catalyst-Model-DBIC-Schema/Changes	2009-05-03 19:13:06 UTC (rev 9996)
@@ -1,5 +1,6 @@
 Revision history for Perl extension Catalyst::Model::DBIC::Schema
 
+        - warn on empty schema
         - create=dynamic deprecation warning
         - conversion to Moose (of Model, helper to follow)
         - cursor caching support (via ::Role::Caching)

Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Caching.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Caching.pm	2009-05-03 18:57:13 UTC (rev 9995)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Caching.pm	2009-05-03 19:13:06 UTC (rev 9996)
@@ -1,7 +1,7 @@
 package Catalyst::Model::DBIC::Schema::Role::Caching;
 
 use Moose::Role;
-use Carp::Clan '^Catalyst::Model::DBIC::Schema';
+use Carp::Clan '^Catalyst::Model::DBIC::Schema::';
 
 use namespace::clean -except => 'meta';
 

Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Replicated.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Replicated.pm	2009-05-03 18:57:13 UTC (rev 9995)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Role/Replicated.pm	2009-05-03 19:13:06 UTC (rev 9996)
@@ -2,7 +2,7 @@
 
 use Moose::Role;
 use Moose::Autobox;
-use Carp::Clan '^Catalyst::Model::DBIC::Schema';
+use Carp::Clan '^Catalyst::Model::DBIC::Schema::';
 
 use Catalyst::Model::DBIC::Schema::Types 'ConnectInfos';
 
@@ -60,12 +60,14 @@
     } else {
         $self->storage_type('::DBI::Replicated');
     }
+
+    $self->connect_info->{balancer_type} ||= '::Random';
 };
 
 after finalize => sub {
     my $self = shift;
 
-    $self->storage->connect_replicants($self->replicants->flatten);
+    $self->storage->connect_replicants(map [ $_ ], $self->replicants->flatten);
 };
 
 =head1 SEE ALSO

Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm	2009-05-03 18:57:13 UTC (rev 9995)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm	2009-05-03 19:13:06 UTC (rev 9996)
@@ -3,10 +3,10 @@
 use MooseX::Types
     -declare => [qw/ConnectInfo ConnectInfos Replicants SchemaClass/];
 
+use Carp::Clan '^Catalyst::Model::DBIC::Schema::';
 use MooseX::Types::Moose qw/ArrayRef HashRef Str ClassName/;
 use Scalar::Util 'reftype';
 use List::MoreUtils 'all';
-use Carp;
 
 use namespace::clean -except => 'meta';
 
@@ -57,16 +57,16 @@
         for my $i (0..1) {
             my $extra = shift @$_;
             last unless $extra;
-            croak "invalid connect_info" unless reftype $extra eq 'HASH';
+            die "invalid connect_info" unless reftype $extra eq 'HASH';
 
             %connect_info = (%connect_info, %$extra);
         }
 
-        croak "invalid connect_info" if @$_;
+        die "invalid connect_info" if @$_;
     } elsif (@$_ == 1 && reftype $_->[0] eq 'HASH') {
         return $_->[0];
     } else {
-        croak "invalid connect_info";
+        die "invalid connect_info";
     }
 
     \%connect_info;

Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm	2009-05-03 18:57:13 UTC (rev 9995)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm	2009-05-03 19:13:06 UTC (rev 9996)
@@ -7,7 +7,7 @@
 
 our $VERSION = '0.24';
 
-use Carp::Clan '^Catalyst::Model::DBIC::Schema';
+use Carp::Clan '^Catalyst::Model::DBIC::Schema::';
 use Data::Dumper;
 use DBIx::Class ();
 use Scalar::Util 'reftype';
@@ -418,7 +418,7 @@
             $self->connect_info($schema_class->storage->connect_info);
         }
         else {
-            croak "Either ->config->{connect_info} must be defined for $class"
+            die "Either ->config->{connect_info} must be defined for $class"
                   . " or $schema_class must have connect info defined on it."
 		  . " Here's what we got:\n"
 		  . Dumper($self);
@@ -487,7 +487,13 @@
     my $class = $self->_class_name;
 
     no strict 'refs';
-    foreach my $moniker ($self->schema->sources) {
+
+    my @sources = $self->schema->sources;
+
+    die "No sources found (did you forget to define your tables?)"
+        unless @sources;
+
+    foreach my $moniker (@sources) {
         my $classname = "${class}::$moniker";
         *{"${classname}::ACCEPT_CONTEXT"} = sub {
             shift;




More information about the Catalyst-commits mailing list