Adding ability to update / patch by sku, adding uniqueness constraint violation checks
This commit is contained in:
1 parent
af5343da0c
commit
d8db87c13e
13 files changed
+541
-13
No files matched your search
@@ -81,6 +81,12 @@ async def update_role(
|
||||
status_code=status.HTTP_404_NOT_FOUND, detail="Role not found"
|
||||
)
|
||||
changes = payload.model_dump(exclude_unset=True)
|
||||
if "name" in changes:
|
||||
existing = await role_crud.get_by_name(db, changes["name"])
|
||||
if existing is not None and existing.id != role.id:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT, detail="Role already exists"
|
||||
)
|
||||
role = await role_crud.update(db, role, changes)
|
||||
await audit_crud.log(
|
||||
db,
|
||||
|
||||
Reference in new issue
Block a user