我目前有这个代码:
qbc_q = cmdata_sess.query(cast(QBConfiguration.id, Text).label("cfg_id"),
QBConfiguration.branch.label("branch"),
QBConfiguration.description.label(
"cfg_description"),
QBConfiguration.name.label("cfg_name"))
tcc_q = cmdata_sess.query(TCConfiguration.id.label("cfg_id"),
TCConfiguration.branch.label("branch"),
TCConfiguration.name.label('cfg_description'),
TCConfiguration.name.label("cfg_name"))
configs_subq = qbc_q.union(tcc_q).subquery("config")
如您所见,标签非常多余。举个例子,我想以某种方式说:
configs_subq.labels(["cfg_id", "branch", "cfg_description", "cfg_name"])
有没有办法让这段代码更简洁?