我有一个SQLAlchemy模型的特殊验证器:
class MyModel(db.Model):
id = Column(Integer, primary_key=True)
name = Column(Unicode(length=16), default=u'')
is_active = Column(Boolean, default=False)
@listens_for(MyModel, 'before_update')
def complex_constraint(mapper, connection, target):
# checks uniqueness of an instance using complex rule
....
当我尝试删除MyModel
的实例时,由于某种原因,SQLAlchemy调用before_update
处理程序:
MyModel.query.filter(MyModel.name=='Dave').delete()
所以我的问题:
before_update
处理程序
实例