Ignore:
Timestamp:
22/12/11 17:33:24 (8 years ago)
Author:
mnagni
Message:

Again uncompleted deployment in DB. Tomorrow have to check better the primaryjoins!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/xmi2sqlalchemy/trunk/src/main/resources/velocity/python/sqlAlchemyTables.vm

    r8027 r8040  
    2424#macro( fk $foreignKey, $tableModel) 
    2525#set ($fkName = ${foreignKey.tableModel.associatedClass.name.toLowerCase()}) 
    26 #set ($totalName = "${fkName}_${foreignKey.parentAttributeName.toLowerCase()}") 
    27 Column('${totalName}', Integer, ForeignKey('${fkName}.${fkName}_id'#checkUseAlter($foreignKey, $fkName))), 
     26#set ($relName = ${foreignKey.parentAttributeName}) 
     27#if($foreignKey.associatedRelationship.isOneToOne() || !$foreignKey.associatedRelationship.useList) 
     28Column('${fkName}_${relName}_id', Integer, ForeignKey('${fkName}.id'#checkUseAlter($foreignKey, $fkName))), 
     29#else 
     30Column('${fkName}_${relName}', Integer, ForeignKey('${fkName}.id'#checkUseAlter($foreignKey, $fkName))), 
     31#end 
    2832#end 
    2933 
    3034#macro( primaryKey $tableModel) 
    3135#set ($tn = ${tableModel.associatedClass.name.toLowerCase()}) 
    32 ${tab}Column('${tn}_id', Integer, Sequence('${tn}_id_seq'), primary_key=True), 
    33 #if($tableModel.inherited && $tableModel.inherited.size() > 0) 
    34         #foreach( $parent in $tableModel.inherited) 
    35                 #set ($pn = ${parent.associatedClass.name.toLowerCase()}) 
    36                 ${tab}Column('${pn}_id', Integer, ForeignKey('${pn}.${pn}_id')),#end 
    37 #end 
     36${tab}Column('id', Integer, Sequence('${tn}_id_seq'), primary_key=True), 
     37##if($tableModel.inherited && $tableModel.inherited.size() > 0) 
     38        ##foreach( $parent in $tableModel.inherited) 
     39                ##set ($pn = ${parent.associatedClass.name.toLowerCase()}) 
     40                ##${tab}Column('_${pn}', Integer, ForeignKey('${pn}.${pn}_id')),#end 
     41##end 
    3842#end 
    3943 
Note: See TracChangeset for help on using the changeset viewer.