@@ -144,7 +144,7 @@ async def write_category(
144144 db : Annotated[AsyncSession, Depends(async_get_db)],
145145):
146146 category_row = await crud_categories.exists(db = db, name = category.name)
147- if category_row:
147+ if category_row is True :
148148 raise DuplicateValueException(" Category name already exists" )
149149
150150 return await crud_categories.create(db = db, object = category)
@@ -180,7 +180,7 @@ async def read_category(
180180 id = category_id,
181181 is_deleted = False
182182 )
183- if not db_category:
183+ if db_category is None :
184184 raise NotFoundException(" Category not found" )
185185
186186 return db_category
@@ -195,12 +195,12 @@ async def patch_category(
195195 db : Annotated[AsyncSession, Depends(async_get_db)],
196196):
197197 db_category = await crud_categories.get(db = db, id = category_id, is_deleted = False )
198- if not db_category:
198+ if db_category is None :
199199 raise NotFoundException(" Category not found" )
200200
201- if values.name:
201+ if values.name is True :
202202 category_row = await crud_categories.exists(db = db, name = values.name)
203- if category_row and category_row[" id" ] != category_id:
203+ if category_row is True and category_row[" id" ] != category_id:
204204 raise DuplicateValueException(" Category name already exists" )
205205
206206 return await crud_categories.update(db = db, object = values, id = category_id)
@@ -214,7 +214,7 @@ async def erase_category(
214214 db : Annotated[AsyncSession, Depends(async_get_db)],
215215):
216216 db_category = await crud_categories.get(db = db, id = category_id, is_deleted = False )
217- if not db_category:
217+ if db_category is None :
218218 raise NotFoundException(" Category not found" )
219219
220220 await crud_categories.delete(db = db, db_row = db_category, garbage_collection = False )
0 commit comments