[Dbix-class] [PATCH] Schema::Loader add components per-class
Kieren Diment
diment at gmail.com
Tue Jul 7 00:25:37 GMT 2009
On 07/07/2009, at 10:14 AM, Tom Lanyon wrote:
> Hi list,
>
> I needed to add some components to some classes but not others; I
> expected this to be a fairly normal operation but DBIC-Schema-Loader
> didn't seem to be able to do it...
>
> Attached is a simple patch that 'works for me' against current SVN
> trunk. Comments? Suggestions?
>
> -Tom
>
> <loader-component_overrides.patch>
Here's a script from the new Catalyst book that seems to achieve what
you wanted, at least to some degree. In this case you regenerate the
classes for particular tables to which you want to add specific
components, so for lots of tables and lots of specific components this
approach is repetitive. I don't know how close this is to doing what
your patch achieves, but I do note that to be accepted into DBIC, your
patch would need to include suitable tests.
#!/usr/bin/perl
use warnings;
use strict;
use FindBin qw/$Bin/;
use DBIx::Class::Schema::Loader qw/ make_schema_at /;
my %options;
if (@ARGV) {
my $table = shift @ARGV;
%options = ( constraint => $table,
components => [@ARGV]);
}
make_schema_at("Zotero::Schema",
{
%options,
debug => 1,
relationships => 1,
use_namespaces => 1,
dump_directory => "$Bin/../lib" ,
},
["dbi:SQLite:dbname=$Bin/../zotero.sqlite",
"",""]);
=head1 make_zotero_schema.pl [table name] [components]
Make the DBIC schema from the zotero db, optionally limit it to a
particular table, and adding specific components to the table.
=cut
More information about the DBIx-Class
mailing list