We have the CRUD functions in our API which is using FastAPI and SQLAlchemy.
For update functions we have the below code:
def update_user(
user_id: uuid.UUID,
db: Session,
update_model: UserUpdateModel,
) -> bool:
query = (
db.query(User)
.filter(
User.user_id == user_id,
)
.update(update_model, synchronize_session=False)
)
try:
db.commit()
except IntegrityError as e:
if isinstance(e.orig, PG2UniqueViolation):
raise UniqueViolation from e
return bool(query)
What exactly does the 'synchronize_session=False' do here?
What is the best value for it? False or Fetch...?
Is it critical if we don't use it?