on dev help sign in
move a thing
46d5803Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+15−15
@@ -351,21 +351,6 @@ renderConflictClause = \case
351UPDATE statements
351UPDATE statements
352-----------------------------------------}
352-----------------------------------------}
353
353
354−-- | An `update` command changes the values of the specified columns
355−-- in all rows that satisfy the condition.
356−--
357−-- >>> :{
358−-- let
359−-- manipulation :: Manipulation
360−-- '[ "tab" ::: '[] :=>
361−-- '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
362−-- , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ]] '[] '[]
363−-- manipulation =
364−-- update_ #tab (Set 2 `As` #col1 :* Same `As` #col2 :* Nil)
365−-- (#col1 ./= #col2)
366−-- in renderManipulation manipulation
367−-- :}
368−-- "UPDATE tab SET col1 = 2 WHERE (col1 <> col2);"
369update
354update
370 :: ( SOP.SListI columns
355 :: ( SOP.SListI columns
371 , SOP.SListI results
356 , SOP.SListI results
@@ -396,6 +381,21 @@ update table columns wh returning = UnsafeManipulation $
396 Set expression `As` column -> Just $
381 Set expression `As` column -> Just $
397 renderAlias column <+> "=" <+> renderExpression expression
382 renderAlias column <+> "=" <+> renderExpression expression
398
383
384+-- | An `update` command changes the values of the specified columns
385+-- in all rows that satisfy the condition.
386+--
387+-- >>> :{
388+-- let
389+-- manipulation :: Manipulation
390+-- '[ "tab" ::: '[] :=>
391+-- '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
392+-- , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ]] '[] '[]
393+-- manipulation =
394+-- update_ #tab (Set 2 `As` #col1 :* Same `As` #col2 :* Nil)
395+-- (#col1 ./= #col2)
396+-- in renderManipulation manipulation
397+-- :}
398+-- "UPDATE tab SET col1 = 2 WHERE (col1 <> col2);"
399update_
399update_
400 :: ( SOP.SListI columns
400 :: ( SOP.SListI columns
401 , Has tab schema table
401 , Has tab schema table