我正在使用Github Actions构建docker映像,并想用分支名称标记映像,我只找到了GITHUB_REF变量,但结果是refs/heads/feature-branch-1,我只需要feature-branch-1。
我有三个具有继承和关系的模型,我想将查询缓存到这个模型。
class Person(Base):
__tablename__ = 'person'
id = Column(Integer, primary_key=True)
name = Column(String(100), nullable=False)
type = Column(String(50))
__mapper_args__ = {
'polymorphic_identity': 'object',
'polymorphic_on': type
}
class Man(Person):
__tablename__ = 'man'
id = Column(Integer, ForeignKey('person.id'), primary_key=True)
age = Column(String(100), nullable=False)
__mapper_args__ = {'polymorphic_identity': 'man'}
class Config(Base):
__tablename__ = "config"
id = Column(Integer, primary_key=True)
person = Column(Integer, ForeignKey('person.id'))
address = Column(String)
person_ref = relationship(Person)
Run Code Online (Sandbox Code Playgroud)
还有很多从Personal继承的其他模型。例如,我需要通过Config关系访问Man属性。通常我会这样做:
config = session.query(Config).join(Config.person_ref).filter(Person.type == 'man').first()
print config.person_ref.age
Run Code Online (Sandbox Code Playgroud)
如何使用 dogpile 缓存这样的查询?我可以将查询缓存到Config …