dbicdump [-o <loader_option>=<value> ] <schema_class> <connect_info>
+Examples:
+
+ $ dbicdump -o dump_directory=./lib \
+ -o components='["InflateColumn::DateTime"]' \
+ MyApp::Schema dbi:SQLite:./foo.db '{ quote_char => "\"" }'
+
+ $ dbicdump -o dump_directory=./lib \
+ -o components='["InflateColumn::DateTime"]' \
+ -o preserve_case=1 \
+ MyApp::Schema dbi:mysql:database=foo user pass '{ quote_char => "`" }'
+
=head1 DESCRIPTION
Dbicdump generates a L<DBIx::Class> schema using
Dagfinn Ilmari Mannsåker C<< <ilmari@ilmari.org> >>
+=head1 CONTRIBUTORS
+
+Caelum: Rafael Kitover <rkitover@cpan.org>
+
=head1 LICENSE
This program is free software; you can redistribute it and/or modify it
my ($schema_class, @loader_connect_info) = @ARGV
or pod2usage(1);
+my $dsn = shift @loader_connect_info;
+
+my ($user, $pass) = $dsn =~ /sqlite/i ? ('', '')
+ : splice @loader_connect_info, 0, 2;
+
+my @extra_connect_info_opts = map parse_value($_), @loader_connect_info;
+
+make_schema_at(
+ $schema_class,
+ $loader_options,
+ [ $dsn, $user, $pass, @extra_connect_info_opts ],
+);
+
+exit 0;
+
+sub parse_value {
+ my $value = shift;
+
+ $value = eval $value if $value =~ /^\s*(?:sub\s*\{|q\w?\s*[^\w\s]|[[{])/;
+
+ return $value;
+}
+
sub handle_option {
my ($self, $key, $value) = @_;
die "Unknown option: $key\n"
unless DBIx::Class::Schema::Loader::Base->can($key);
- $value = eval $value if $value =~ /^\s*(?:sub\s*\{|q\w?\s*[^\w\s]|[[{])/;
+ $value = parse_value $value;
$loader_options->{$key} = $value;
}
-make_schema_at(
- $schema_class,
- $loader_options,
- \@loader_connect_info,
-);
+1;
+
+__END__
error => qr/My::MissingResultBaseClass.*is not installed/,
);
+# test quote_char in connect_info for dbicdump
+$t->dump_test(
+ classname => 'DBICTest::DumpMore::1',
+ extra_connect_info => [
+ '',
+ '',
+ { quote_char => '"' },
+ ],
+ warnings => [
+ qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
+ qr/Schema dump completed/,
+ ],
+);
+
done_testing;
my @warns;
eval {
local $SIG{__WARN__} = sub { push(@warns, @_) };
- $schema_class->connect(_get_dsn(\%tdata));
+ $schema_class->connect(_get_connect_info(\%tdata));
};
my $err = $@;
push @cmd, '-o', "$opt=$val";
}
- push @cmd, $tdata{classname}, _get_dsn(\%tdata);
+ my @connect_info = _get_connect_info(\%tdata);
+
+ for my $info (@connect_info) {
+ $info = dumper_squashed $info if ref $info;
+ }
+
+ push @cmd, $tdata{classname}, @connect_info;
# make sure our current @INC gets used by dbicdump
use Config;
return @warnings;
}
-sub _get_dsn {
+sub _get_connect_info {
my $opts = shift;
my $test_db_class = $opts->{test_db_class} || 'make_dbictest_db';
${$test_db_class . '::dsn'};
};
- return $dsn;
+ return ($dsn, @{ $opts->{extra_connect_info} || [] });
}
sub _check_error {