[Catalyst-commits] r9385 -
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Mon Feb 23 18:52:30 GMT 2009
Author: caelum
Date: 2009-02-23 18:52:29 +0000 (Mon, 23 Feb 2009)
New Revision: 9385
Modified:
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm
Log:
C::Helper::M::DBIC::SChema -- better Schema::Loader arg parsing, and a bugfix
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 16:57:15 UTC (rev 9384)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm 2009-02-23 18:52:29 UTC (rev 9385)
@@ -59,11 +59,10 @@
# 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
+ # Same, but with extra Schema::Loader args (separate multiple values by commas):
+ script/myapp_create.pl model CatalystModelName DBIC::Schema MyApp::SchemaClass create=static db_schema=foodb components=Foo,Bar exclude='^wibble|wobble$' 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
+ # See DBIx::Class::Schema::Loader::Base for list of options
# Create a dynamic DBIx::Class::Schema::Loader-based Schema,
# and a Model which references it:
@@ -94,6 +93,17 @@
shift @connect_info;
}
+ my %extra_args;
+ while (@connect_info && $connect_info[0] !~ /^dbi:/) {
+ my ($key, $val) = split /=/, shift(@connect_info);
+
+ if ((my @vals = split /,/ => $val) > 1) {
+ $extra_args{$key} = \@vals;
+ } else {
+ $extra_args{$key} = $val;
+ }
+ }
+
if(@connect_info) {
$helper->{setup_connect_info} = 1;
my @helper_connect_info = @connect_info;
@@ -118,20 +128,6 @@
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) {
@@ -163,6 +159,15 @@
push @components, @{ delete $extra_args{components} };
}
+ for my $re_opt (qw/constraint exclude/) {
+ $extra_args{$re_opt} = qr/$extra_args{$re_opt}/
+ if exists $extra_args{$re_opt};
+ }
+
+ if (exists $extra_args{moniker_map}) {
+ die "The moniker_map option is not currently supported by this helper, please write your own DBIx::Class::Schema::Loader script if you need it."
+ }
+
make_schema_at(
$schema_class,
{
More information about the Catalyst-commits
mailing list