Hi,
I have manged to set up joined and single table inheritance mappings.
When relationships get involved I need help.
I would like to use the state pattern. Class Applicant delegates to a
subclass of State.
applicant_table = Table('applicant', metadata,
Column('applicant_id',Integer, primary_key=True),
Column('_state', Integer, ForeignKey('applicantstate.state_id')),
)
appstate_table = Table('applicantstate', metadata,
Column('state_id',Integer, primary_key=True),
Column('type', String(30),nullable=False),
Column('_givenName', String(40))
)
# applicant - state relationship, one to one, SQLAlchemy-0.5.8-
#mapper(Applicant, applicant_table, properties={
# 'applicantstate':relation(State, uselist=False,
backref='applicant')
#})
mapper(Applicant, applicant_table, properties={
'applicantstate':relation(State, backref=backref('applicant',
uselist=False))
})
I tried both relationships and get:
ProgrammingError: (ProgrammingError) can't adapt '
INSERT INTO applicant (applicant_id, _state)
VALUES (%(applicant_id)s, %(_state)s)'
{'_state': <tg21tut.model.Applicant2.NewStdApp object at 0x9034bec>,
'applicant_id': 1L}
I have omitted the single table inheritance mappings.
Thank you
Ernst
--
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.