fix sqlalchemy event bug