I'd like to represent a Correspondent object, which can refer to two
separate objects
Corr_1
- id
- email_address
Corr_2
- id
- email_address
Correspondent
- id
- corr_1.id
- corr_2.id
But I have two problems:
I'm using MySQL, so I can't use a check constraint to ensure that only one
of the corr_*.id fields can be populated. Is it it a bad idea to enforce
the constraint at the SQLAlchemy level, by doing
if all(corr1.id, corr2.id) or not any(corr_1.id, corr2.id):
raise …
in my __init__?
My second problem relates to then being able to retrieve the related
.email_address attribute. My naïve relationship above obviously won't work
for that. Any pointers would be greatly appreciated.
--
steph
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sqlalchemy/-/QjLuU4Ue9pEJ.
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.