Hello. For “many-to-many relations” I use link table with non-standard
field names. An example of such a model in the attached file. When I get the
next generation of yaml:
refs_metro
…
relations:
Okrugs:
class: refs_moscow_okrug
refClass: refs_metro_okrug_link
foreignAlias: Metros
local: id_metro
foreign: id_okrug
And must be generated:
refs_metro
…
relations:
Okrugs:
class: refs_moscow_okrug
refClass: refs_metro_okrug_link
foreignAlias: Metros
local: id_metro
foreign: id_okrug
To solve this problem, I introduced a new tag in the comment, which lists the
names of the fields for relation.
{doctrine:mnRelationsSelf}
Okrugs=>refs_metro_okrug_link=>id_okrug=>id_metro=>refs_moscow_okrugs=>Metros
{/doctrine:mnRelationsSelf}
For processing added the following code (version 0.4.2dev, after string number
855):
-- add m:n relations with self names
mnRelationsSelf = getCommentToken(tbl.comment, "mnRelationsSelf")
if ( mnRelationsSelf ~= nil ) then
for localAlias, refClass, id_foreign, id_local, foreignClass, foreignAlias in string.gmatch(mnRelationsSelf, "(%a+)=>([%a%d_]+)=>([%a%d_]+)=>([%a%d_]+)=>([%a%d_]+)=>(%a+)") do
refClass = getTable( tables, refClass )
foreignClass = getTable( tables, foreignClass )
relations = relations .. " " .. localAlias .. ":\n"
relations = relations .. " class: " .. buildEntityName( foreignClass ) .. "\n"
relations = relations .. " refClass: " .. buildEntityName( refClass ) .. "\n"
relations = relations .. " foreignAlias: " .. foreignAlias .. "\n"
relations = relations .. " local: " .. id_local .. "\n"
relations = relations .. " foreign: " .. id_foreign .. "\n"
end
end
However, I believe its implementation is wrong - the field names should be
taken from links. Do, please, to the default field names were taken from the
connection attributes of link.
If this is difficult, you can include in future versions of my code, so I can
safely update the plugin?
Original issue reported on code.google.com by MagzNiki...@gmail.com on 23 Jun 2010 at 8:33
Original issue reported on code.google.com by
MagzNiki...@gmail.com
on 23 Jun 2010 at 8:33Attachments: