[Dbix-class] SQL::Translator::Parser::DBIx::Class
Stephan Szabo
sszabo at megazone.bigpanda.com
Sun Mar 26 22:05:28 CEST 2006
While playing with SQL::Translator to generate sql scripts from schemas, I
noticed that the DBIx::Class parser seemed to grab only one column of
multi-column relationships. It looks like just making it work across
$rel_info->{cond} into an array rather than taking only the first key
should work, something like:
my @cond = keys(%{$rel_info->{cond}});
my @keys = map {/^\w+\.(\w+)$/} @cond;
my @refkeys = map {$rel_info->{cond}->{$_} =~ /^\w+\.(\w+)$/} @cond;
if($rel_table)
{
$table->add_constraint(
type => 'foreign_key',
name => "fk_$keys[0]",
fields => \@keys,
reference_fields => \@refkeys,
reference_table => $rel_table,
);
}
Does that seem reasonable?
More information about the Dbix-class
mailing list