I am trying to update some records in the table using the following code:
session.query(Post).filter(
Post.title.ilike("%Regular%")
).update({"status": False})
But the problem is that the code throws the following exception:
InvalidRequestError: Could not evaluate current criteria in Python: "Cannot evaluate BinaryExpression with operator <function ilike_op at 0x7fbb88450ea0>". Specify 'fetch' or False for the synchronize_session parameter.
However, if I pass synchronize_session=False
to the update()
, it works miraculously.
session.query(Post).filter(
Post.title.ilike("%Regular%")
).update({"status": False}, synchronize_session=False)
So what the use of synchronize_session
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…