- attached db.txt
ForeignKey Error
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)
-
Account Deleted -
repo owner - changed status to wontfix
your two tables have two ways of being joined together (2 foreign keys), hence relation() requires additional detail (as the error message states).
Additionally, the potential for mutually-dependent rows will require that you use post_update=True.
A full example of this scenario is at : http://www.sqlalchemy.org/docs/mappers.html#rows-that-point-to-themselves-mutually-dependent-rows
-
repo owner - removed milestone
Removing milestone: 0.6.0 (automated comment)
- Log in to comment
code script