I'm using the declarative style and unable to to get a mapper to initialize.

Here's a simplified version of the class from client_transaction.py:

class ClientTransaction(Base):

    __tablename__ = 'client_transactions'

    id = Column(Integer, primary_key=True)
    client_promotion_id = Column(Integer, 
ForeignKey('clients_promotions.id'))
    
    client_promotion = relationship('ClientPromotion', 
primaryjoin='ClientTransction.client_promotion_id == ClientPromotion.id')


And here's the error:

InvalidRequestError: One or more mappers failed to initialize - can't 
proceed with initialization of other mappers.  Original exception was: When 
initializing mapper Mapper|ClientTransaction|client_transactions, expression 
'ClientPromotion' failed to locate a name ("name 'ClientPromotion' is not 
defined"). If this is a class name, consider adding this relationship() to 
the <class 'uber.model.client_transaction.ClientTransaction'> class after 
both dependent classes have been defined.


Which seems to be in conflict with this statement from the docs:

In addition to the main argument for relationship(), other arguments which 
depend upon the columns present on an as-yet undefined class may also be 
specified as strings.


For the sake of reference, here's the other class in client_promotion.py as 
well:

class ClientPromotion(SmartModel):
    
    __tablename__ = 'clients_promotions'

 

    id = Column(Integer, primary_key=True)

    client_transaction_id = Column(Integer, 
ForeignKey('client_transactions.id'))

    client_transaction = relationship('ClientTransaction', 
primaryjoin='ClientPromotion.client_transaction_id == ClientTransaction.id', 
uselist=False)


Any help on getting a 'client_promotion' attribute on the 
'ClientTransaction' class would be greatly appreciated. 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to