So, after the sqlalchemy developers fixed this bug, this problem no longer occurs if you upgrade sqlalchemy to 2.0.36