@@ -252,11 +252,11 @@ pgInsertManyEntitiesId ents' =
252252--  'pgInsertManyEntitiesId' does 
253253pgInsertManyEntities  ::  forall  a  m .  (Entity  a , HasPostgres  m , MonadLogger  m , ToRow  a )
254254                     =>  [a ]
255-                      ->  m  () 
256- pgInsertManyEntities []  =  return  () 
255+                      ->  m  Int64 
256+ pgInsertManyEntities []  =  return  0 
257257pgInsertManyEntities ents' = 
258258    let  ents =  NL. fromList ents'
259-     in  void  $   pgExecute $  insertManyEntities ents
259+     in  pgExecute $  insertManyEntities ents
260260
261261
262262{- |  Delete entity.
@@ -267,19 +267,21 @@ rmUser uid = do
267267    pgDeleteEntity uid 
268268@ 
269269
270+ Return 'True' if row was actually deleted. 
270271-} 
271272
272273pgDeleteEntity  ::  forall  a  m .  (Entity  a , HasPostgres  m , MonadLogger  m , ToField  (EntityId  a ), Functor m )
273274               =>  EntityId  a 
274-                ->  m  () 
275+                ->  m  Bool 
275276pgDeleteEntity eid = 
276277    let  p =  Proxy  ::  Proxy  a 
277-     in  (const  () ) <$>  pgExecute [sqlExp |DELETE FROM ^{mkIdent $ tableName p}
278-                                         WHERE id = #{eid}|]
278+     in  fmap  (1  == )
279+        $  pgExecute [sqlExp |DELETE FROM ^{mkIdent $ tableName p}
280+                            WHERE id = #{eid}|]
279281
280282
281- {- |  Update entity using 'ToMarkedRow' instanced value. Requires 'Proxy' while 
282- 'EntityId' is not a data type. 
283+ {- |  Update entity using 'ToMarkedRow' instanced value. Requires 'Proxy'
284+ while  'EntityId' is not a data type.
283285
284286@ 
285287fixUser :: Text -> EntityId User -> Handler () 
@@ -293,19 +295,21 @@ fixUser username uid = do
293295              ("name", mkValue username)] 
294296@ 
295297
298+ Returns 'True' if record was actually updated and 'False' if there was 
299+ not row with such id (or was more than 1, in fact) 
296300-} 
297301
298302pgUpdateEntity  ::  forall  a  b  m .  (ToMarkedRow  b , Entity  a , HasPostgres  m , MonadLogger  m ,
299303                           ToField  (EntityId  a ), Functor m , Typeable  a , Typeable  b )
300304               =>  EntityId  a 
301305               ->  b 
302-                ->  m  () 
306+                ->  m  Bool 
303307pgUpdateEntity eid b = 
304308    let  p =  Proxy  ::  Proxy  a 
305309        mr =  toMarkedRow b
306310    in  if  L. null  $  unMR mr
307-        then  return  () 
308-        else  fmap  (const   () )
311+        then  return  False 
312+        else  fmap  (1   == )
309313            $  pgExecute [sqlExp |UPDATE ^{mkIdent $ tableName p}
310314                                SET ^{mrToBuilder ", " mr}
311315                                WHERE id = #{eid}|]
0 commit comments