[Catalyst-commits] r11607 - in Catalyst-Model-DBIC-Schema/trunk: . lib/Catalyst/Helper/Model/DBIC lib/Catalyst/Model/DBIC

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Sun Oct 18 05:15:59 GMT 2009


Author: caelum
Date: 2009-10-18 05:15:58 +0000 (Sun, 18 Oct 2009)
New Revision: 11607

Modified:
   Catalyst-Model-DBIC-Schema/trunk/Changes
   Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Helper/Model/DBIC/Schema.pm
   Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm
Log:
change no sources error to warning, write connect_info to model with no create= option

Modified: Catalyst-Model-DBIC-Schema/trunk/Changes
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/Changes	2009-10-17 17:31:48 UTC (rev 11606)
+++ Catalyst-Model-DBIC-Schema/trunk/Changes	2009-10-18 05:15:58 UTC (rev 11607)
@@ -1,5 +1,9 @@
 Revision history for Perl extension Catalyst::Model::DBIC::Schema
 
+0.30  
+        - change no sources error to a warning (with a way to turn it off)
+        - write connect_info to Model without a create= option as well
+
 0.29  Mon Sep  7 15:31:29 EDT 2009
         - support for coderef connect_info's
 

Modified: Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Helper/Model/DBIC/Schema.pm
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Helper/Model/DBIC/Schema.pm	2009-10-17 17:31:48 UTC (rev 11606)
+++ Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Helper/Model/DBIC/Schema.pm	2009-10-18 05:15:58 UTC (rev 11607)
@@ -4,7 +4,7 @@
 use Moose;
 no warnings 'uninitialized';
 
-our $VERSION = '0.29';
+our $VERSION = '0.30';
 $VERSION = eval $VERSION;
 
 use Carp;
@@ -188,21 +188,21 @@
             $self->_parse_loader_args(\@args);
 
             $helper->{loader_args} = $self->_build_helper_loader_args;
+        }
+    }
 
-            my $dbi_dsn_part;
-            if (first { ($dbi_dsn_part) = /^(dbi):/i } @args) {
-                die
+    my $dbi_dsn_part;
+    if (first { ($dbi_dsn_part) = /^(dbi):/i } @args) {
+        die
 qq{DSN must start with 'dbi:' not '$dbi_dsn_part' (case matters!)}
-                    if $dbi_dsn_part ne 'dbi';
+            if $dbi_dsn_part ne 'dbi';
 
-                $helper->{setup_connect_info} = 1;
+        $helper->{setup_connect_info} = 1;
 
-                $helper->{connect_info} =
-                    $self->_build_helper_connect_info(\@args);
+        $helper->{connect_info} =
+            $self->_build_helper_connect_info(\@args);
 
-                $self->_parse_connect_info(\@args);
-            }
-        }
+        $self->_parse_connect_info(\@args);
     }
 
     $helper->{generator} = ref $self;

Modified: Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm	2009-10-17 17:31:48 UTC (rev 11606)
+++ Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm	2009-10-18 05:15:58 UTC (rev 11607)
@@ -5,7 +5,7 @@
 extends 'Catalyst::Model';
 with 'CatalystX::Component::Traits';
 
-our $VERSION = '0.29';
+our $VERSION = '0.30';
 $VERSION = eval $VERSION;
 
 use namespace::autoclean;
@@ -546,8 +546,15 @@
 
     my @sources = $self->schema->sources;
 
-    die "No sources found (did you forget to define your tables?)"
-        unless @sources;
+    unless (@sources) {
+        warn <<'EOF' unless $ENV{CMDS_NO_SOURCES};
+******************************* WARNING ***************************************
+* No sources found (did you forget to define your tables?)                    *
+*                                                                             *
+* To turn off this warning, set the CMDS_NO_SOURCES environment variable.     *
+*******************************************************************************
+EOF
+    }
 
     foreach my $moniker (@sources) {
         my $classname = "${class}::$moniker";
@@ -640,6 +647,17 @@
 
 __PACKAGE__->meta->make_immutable;
 
+=head1 ENVIRONMENT
+
+=over 4
+
+=item CMDS_NO_SOURCES
+
+Set this variable if you will be using schemas with no sources (tables) to
+disable the warning. The warning is there because this is usually a mistake.
+
+=back
+
 =head1 SEE ALSO
 
 General Catalyst Stuff:




More information about the Catalyst-commits mailing list