我有以下 SqlAlchemy 配置(为简洁起见,伪代码):
class A(BaseModel):
id: column...
b_id: column...
b: relationship...
class B(BaseModel):
id: column...
name: column...
class C(BaseModel):
id: column...
b_id: column...
b: relationship...
我有一个 Marshmallow SqlAlchemy 模式,如下所示:
class BSchema(SqlAlchemyAutoSchema):
class Meta:
model = B
include_fk = True
class ASchema(SqlAlchemyAutoSchema):
class Meta:
model = A
include_relationships = False
include_fk = True
load_instance = True
b = Nested(BSchema, many=False)
我正在使用的查询如下所示:
session.query(A, C.id)
.join(B,A.b_id = B.id)
.join(C,C.b_id = B.id)
.all()
我怎样才能C.id
在我的ASchema
课程中加入,以便我以后可以访问它?