Skip to content

Commit

Permalink
Merge pull request #14 from swarmauri/dev
Browse files Browse the repository at this point in the history
update  crouton
  • Loading branch information
cobycloud authored Nov 20, 2024
2 parents f8d92ed + ba2dc08 commit 5157b23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions pkgs/crouton/crouton/core/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,16 @@ def route(
try:
db_model: Model = self._get_one()(item_id, db)

for key, value in model.dict(exclude={self._pk}).items():
# Use exclude_unset=True to only update provided fields
update_data = model.dict(exclude={self._pk}, exclude_unset=True)

for key, value in update_data.items():
if hasattr(db_model, key):
setattr(db_model, key, value)

db.commit()
db.refresh(db_model)

return db_model
except IntegrityError as e:
db.rollback()
Expand Down
2 changes: 1 addition & 1 deletion pkgs/crouton/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "crouton"
version = "0.0.4.dev5"
version = "0.0.4.dev6"
description = "A repository to enable API CRUD Routing"
authors = ["Jacob Stewart <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 5157b23

Please sign in to comment.