Subject: | Strang character in key when using multiple foreing keys |
Hello,
I found a bug when a constraint in a table has more than one foreign
key, the function _table_fk_info returns a strange character (`)
appended to the key, for instance:
CREATE TABLE `table` (
`idt` int (10) unsigned NOT NULL auto_increment,
`idt_table1` int (10) unsigned NOT NULL auto_increment,
`idt_table2` int (10) unsigned NOT NULL auto_increment,
`idt_table3` int (10) unsigned NOT NULL auto_increment,
PRIMARY KEY (`idt`),
CONSTRAINT `fk` FOREIGN KEY (`idt_table1`, `idt_table2`,
`idt_table3`) REFERENCES `table4` (`idt_table1`, `idt_table2`,
`idt_table3`),
[...]
)
I looked into the code and I found a solution:
- in function _table_fk_info you have:
my (@reldata) = ($table_def =~ /CONSTRAINT `.*` FOREIGN KEY \(`(.*)`\)
REFERENCES `(.*)` \(`(.*)`\)/ig);
- it doesn't seem to deal with more than one foreign key
I attached a patch which fixed for me, I hope it helps
I/IL/ILMARI/DBIx-Class-Schema-Loader-0.04005.tar.gz
Subject: | mysql.pm.patch |
--- mysql.pm.orig 2009-01-02 12:00:58.000000000 -0200
+++ mysql.pm 2009-01-02 12:12:50.000000000 -0200
@@ -60,10 +60,10 @@
my $f_cols = shift @reldata;
my @cols = map { s/\Q$self->{_quoter}\E//; lc $_ }
- split(/\s*,\s*/, $cols);
+ split(/`?\s*`?,`?\s*`?/, $cols);
my @f_cols = map { s/\Q$self->{_quoter}\E//; lc $_ }
- split(/\s*,\s*/, $f_cols);
+ split(/`?\s*`?,`?\s*`?/, $f_cols);
push(@rels, {
local_columns => \@cols,