Commits

Fayaz Khan committed d7d3362

properly names the foreign key now

  • Participants
  • Parent commits 2453910

Comments (0)

Files changed (1)

     def _set_parent(self, table):
         referenced_table = table.metadata.tables[
                     self.elements[0].target_fullname.split('.')[0]]
-        for column in self.columns:
-            new_column = getattr(referenced_table.c, column).copy()
+        for column, element in zip(self.columns, self.elements):
+            new_column = getattr(
+                    referenced_table.c,
+                    element.target_fullname.split('.')[1]).copy()
+            new_column.name = column
+            new_column.key = column
             if self.primary_key_flag is not None:
                 new_column.primary_key = self.primary_key_flag
             table.append_column(new_column)
     class B(Base):
         __tablename__ = 'b'
         #id = Column(Integer, primary_key=True, autoincrement=False)
-        __table_args__ = (ImplicitForeignKeyConstraint(['id'], ['a.id']),)
+        __table_args__ = (ImplicitForeignKeyConstraint(['a_id'], ['a.id']),)
     t = (Table(
             'c', Base.metadata,
             #Column('id', Integer, primary_key=True, autoincrement=False),