On Oct 20, 10:41 am, Douglas Wilson <
douglasg.wil...@gmail.com> wrote:
> I want foreign key relationships to just have the lowercased-class
> name whenever possible. I have the below code as part of my
> Convention Manager. The problem is with tables that have multi-column
> foreign keys. First this sub is first called with only one column of
> the foreign key, the f_class gets added to the $used_names, then the
> sub is called with both columns, but the name I'd like to use is
> "used", so I end up with "f_class_obj" as the foreign key method name,
> when I'd like just "f_class". The plain "f_class" method with one
> column is never added as an actual foreign key though, so it seems
> like at least it's filtered out later.
I've tried to come up with a simple test case of this, but since I was
trying at home, I used SQLite, and SQLite doesn't call
Rose::DB::Object::Metadata::Auto::auto_generate_foreign_keys where the
problem occurs (but after examining the function, it's now obvious why
it occurs). I think the columns in FK's should just be grouped by
FK_NAME, not sent incrementally to
ConventionManager::auto_foreign_key_name, but I assume by this line
that FK_NAME is not defined in all databases:
my $fk_id = $fk_info->{'RDBO_FK_ID'} = $fk_info->{'FK_NAME'} ||
$fk_info->{'UK_NAME'};
Using UK_NAME seems like a mistake, because you can have multiple
foreign key columns in a table all pointing to the same primary key
table, though I suppose if FK_NAME is undefined, what else is there to
do? But if FK_NAME is defined, then it ought to work as I've said
before.
-Doug