Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix update column #162

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading