austgl / mysql-workbench-doctrine-plugin

Automatically exported from code.google.com/p/mysql-workbench-doctrine-plugin
GNU Lesser General Public License v3.0
0 stars 0 forks source link

local, foreign keywords needed for mnRelations #46

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi -

I have been able to generate a many-to-many, self referencing relationship 
using MySQL 
Workbench, with the following table structures:

protocol (id:integer autoincrement, name:string)
protocol_protocol (id:integer autoincrement, main_protocol_id:FK to protocol, 
related_protocol_id:FK to protocol)

In the protocol table comments, I added the following:

{doctrine:mnRelations}
RelatedProtocols=>protocol_protocol=>protocol=>Protocols
{/doctrine:mnRelations}

This is fine - except for one thing.  There is an error in generating the YAML, 
because the 'local' 
and 'foreign' keywords are not set for the 'RelatedProtocols' relation in the 
Protocols table.

I would expect that your plugin can detect the name of the FK column, and place 
in the following 
into the 'RelatedProtocols' relation:

local: main_protocol_id
foreign: related_protocol_id

especially if the column names are different than the default (in self 
referencing tables where 
there are more than one FK to the same table, then Doctrine cannot use the 
default 'protocol_id')

Does this make sense?

Original issue reported on code.google.com by scott%sw...@gtempaccount.com on 20 May 2010 at 5:43

GoogleCodeExporter commented 9 years ago

Original comment by johannes...@gmail.com on 21 May 2010 at 2:24

GoogleCodeExporter commented 9 years ago
Have you read this very helpful article about self referencing relations?
http://www.doctrine-project.org/documentation/manual/1_2/en/defining-models:rela
tionships:join-table-associations:self-referencing-nest-relations

You can always use {doctrine:externalRelations/} if something is not working 
properly
for you. On the other hand i'm not really able to imagine the whole 
construction. But
this should work anyways see issue18

have you tried to name the keys mainprotocol_id and relatedprotocol_id?

Original comment by johannes...@gmail.com on 21 May 2010 at 2:36