1
我有以下SQLAlchemy的模型:如何從SQLAlchemy模型中確定子對象的類型?
class PersonConsent(ModelAbstract):
__tablename__ = "personConsent"
id = db.Column(db.Integer, primary_key=True)
patientId = db.Column(db.Integer, db.ForeignKey("person.id"))
authorizedPersonId = db.Column(db.Integer, db.ForeignKey("person.id"))
attachmentId = db.Column(db.Integer)
# Additional models
authorizedPerson = db.relationship("Person", foreign_keys=[authorizedPersonId])
consents = db.relationship("PersonConsentType",
secondary=personConsentToTypeMap,
primaryjoin=id==personConsentToTypeMap.c.consentId,
secondaryjoin=PersonConsentType.id==personConsentToTypeMap.c.consentTypeId)
只給定PersonConsent模型我怎麼確定組成consents
場項目的模式?
例如,像
type(PersonConsent.consents) == PersonConsentType