Skip to content

Commit

Permalink
fix column overwritten in update
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbenav committed Sep 14, 2024
1 parent 7525f74 commit 8eb834b
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions fastcrud/crud/fast_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -2208,7 +2208,7 @@ async def update(
update_data[self.updated_at_column] = datetime.now(timezone.utc)

update_data_keys = set(update_data.keys())
model_columns = {column.name for column in inspect(self.model).c}
model_columns = {_column.name for _column in inspect(self.model).c}
extra_fields = update_data_keys - model_columns
if extra_fields:
raise ValueError(f"Extra fields provided: {extra_fields}")
Expand Down Expand Up @@ -2430,11 +2430,7 @@ async def delete(
update_values[self.is_deleted_column] = True

if update_values:
update_stmt = (
update(self.model)
.filter(*filters)
.values(**update_values)
)
update_stmt = update(self.model).filter(*filters).values(**update_values)
await db.execute(update_stmt)

else:
Expand Down

0 comments on commit 8eb834b

Please sign in to comment.