ForeignKey Error

Issue #1724 resolved
Former user created an issue

database: ms sql server 2000, the table already exists dev os: ubuntu 9.10 python db drive: pyodbc 2.1.7 sa ver: 0.6 beta1

I create two ORM:

class UnitGroup(OrmBase): tablename = 't_UnitGroup'

id = Column('FUnitGroupID', Integer, primary_key=True, nullable=False)
name = Column('FName', String(80), unique=True, nullable=False)
unit_id = Column('FDefaultUnitID', Integer, ForeignKey('t_MeasureUnit.FMeasureUnitID'), nullable=False)
unit = relation('Unit', backref='unitgroups')

class Unit(OrmBase): tablename = 't_MeasureUnit'

id = Column('FMeasureUnitID', Integer, primary_key=True, nullable=False)
unitgroup_id = Column('FUnitGroupID', Integer, ForeignKey(UnitGroup.id), nullable=False)
unitgroup = relation(UnitGroup, backref='units')
number = Column('FNumber', String(30), nullable=False)
shortnumber = Column('FShortNumber', String(30), nullable=True)
name = Column('FName', String(80), nullable=True)
conversation = Column('FConversation', Integer, nullable=True)
coefficient = Column('FCoefficient', Numeric(10, 28), nullable=False)
deleted = Column('FDeleted', SmallInteger, nullable=False)

get the following error:

ArgumentError: Could not determine join condition between parent/child tables on relation Unit.unitgroup. Specify a 'primaryjoin' expression. If this is a many-to-many relation, 'secondaryjoin' is needed as well.

Comments (3)

  1. Log in to comment