[Catalyst-commits] r9383 - in trunk/Catalyst-Model-DBIC-Schema: .
lib/Catalyst/Helper/Model/DBIC lib/Catalyst/Model/DBIC
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Mon Feb 23 05:03:07 GMT 2009
Author: caelum
Date: 2009-02-23 05:03:06 +0000 (Mon, 23 Feb 2009)
New Revision: 9383
Modified:
trunk/Catalyst-Model-DBIC-Schema/Changes
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm
Log:
C::Helper::DBIC::Schema -- parse extra Schema::Loader args
Modified: trunk/Catalyst-Model-DBIC-Schema/Changes
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/Changes 2009-02-23 03:45:21 UTC (rev 9382)
+++ trunk/Catalyst-Model-DBIC-Schema/Changes 2009-02-23 05:03:06 UTC (rev 9383)
@@ -1,8 +1,13 @@
Revision history for Perl extension Catalyst::Model::DBIC::Schema
-0.22 Pending
- - Fix oddly formatted error message.
+0.22 Mon Feb 23 04:47:53 UTC 2009
+ - Fix oddly formatted error message.
- Doc patch to clarify generated classes
+ - Switch to use_namespaces and InflateColumn::DateTime for create=static
+ by default, with backcompat
+ - Switch to MRO::Compat from NEXT
+ - Add support for extra Schema::Loader options such as db_schema and
+ components
0.21 Fri Aug 22 00:26:05 UTC 2008
- doc fix (RT #31848)
Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm 2009-02-23 03:45:21 UTC (rev 9382)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm 2009-02-23 05:03:06 UTC (rev 9383)
@@ -59,6 +59,12 @@
# and a Model which references it:
script/myapp_create.pl model CatalystModelName DBIC::Schema MyApp::SchemaClass create=static dbi:mysql:foodb myuname mypass
+ # Same, but with extra Schema::Loader args such as db_schema:
+ script/myapp_create.pl model CatalystModelName DBIC::Schema MyApp::SchemaClass create=static db_schema=foodb dbi:Pg:dbname=foodb myuname mypass
+
+ # Likewise, for multiple values such as a components:
+ script/myapp_create.pl model CatalystModelName DBIC::Schema MyApp::SchemaClass create=static components=Some::Component components=Some::OtherComponent dbi:Pg:dbname=foodb myuname mypass
+
# Create a dynamic DBIx::Class::Schema::Loader-based Schema,
# and a Model which references it:
script/myapp_create.pl model CatalystModelName DBIC::Schema MyApp::SchemaClass create=dynamic dbi:mysql:foodb myuname mypass
@@ -112,6 +118,20 @@
DBIx::Class::Schema::Loader->use("dump_to_dir:$schema_dir", 'make_schema_at')
or croak "Cannot load DBIx::Class::Schema::Loader: $@";
+ my %extra_args;
+ while (@connect_info && $connect_info[0] !~ /^dbi:/) {
+ my ($key, $val) = split /=/, shift(@connect_info);
+
+ if (exists $extra_args{$key}) {
+ $extra_args{$key} = [ $extra_args{$key} ]
+ unless ref $extra_args{$key};
+
+ push @{ $extra_args{$key} }, $val;
+ } else {
+ $extra_args{$key} = $val;
+ }
+ }
+
my @loader_connect_info = @connect_info;
my $num = 6; # argument number on the commandline for "dbi:..."
for(@loader_connect_info) {
@@ -134,23 +154,29 @@
$compatible = 1 if $schema_code =~ /->load_classes/;
}
- if ($compatible) {
- make_schema_at(
- $schema_class,
- { relationships => 1 },
- \@loader_connect_info,
- );
- } else { # use some saner defaults
- make_schema_at(
- $schema_class,
- {
- relationships => 1,
- use_namespaces => 1,
- components => ['InflateColumn::DateTime']
- },
- \@loader_connect_info,
- );
+ my @components = $compatible ? () : ('InflateColumn::DateTime');
+
+ if (exists $extra_args{components}) {
+ $extra_args{components} = [ $extra_args{components} ]
+ unless ref $extra_args{components};
+
+ push @components, @{ delete $extra_args{components} };
}
+
+ make_schema_at(
+ $schema_class,
+ {
+ relationships => 1,
+ (%extra_args ? %extra_args : ()),
+ (!$compatible ? (
+ use_namespaces => 1
+ ) : ()),
+ (@components ? (
+ components => \@components
+ ) : ())
+ },
+ \@loader_connect_info,
+ );
}
my $file = $helper->{file};
Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm 2009-02-23 03:45:21 UTC (rev 9382)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm 2009-02-23 05:03:06 UTC (rev 9383)
@@ -3,7 +3,7 @@
use strict;
use warnings;
-our $VERSION = '0.23';
+our $VERSION = '0.22';
use base qw/Catalyst::Model Class::Accessor::Fast Class::Data::Accessor/;
use MRO::Compat;
More information about the Catalyst-commits
mailing list