1919--
2020----------------------------------------------------------------------------
2121
22- module Aws.DynamoDb.Commands.UpdateItem where
22+ module Aws.DynamoDb.Commands.UpdateItem
23+ ( UpdateItem (.. )
24+ , updateItem
25+ , AttributeUpdate (.. )
26+ , au
27+ , UpdateAction (.. )
28+ , UpdateItem (.. )
29+ , UpdateItemResponse (.. )
30+ ) where
2331
2432-------------------------------------------------------------------------------
2533import Control.Applicative
@@ -55,7 +63,10 @@ updateItem
5563updateItem tn key ups = UpdateItem tn key ups def def def def
5664
5765
58- type AttributeUpdates = [AttributeUpdate ]
66+ -- | A helper to avoid overlapping instances for 'ToJSON'.
67+ newtype AttributeUpdates = AttributeUpdates {
68+ getAttributeUpdates :: [AttributeUpdate ]
69+ }
5970
6071
6172data AttributeUpdate = AttributeUpdate {
@@ -77,7 +88,7 @@ au a = AttributeUpdate a def
7788
7889
7990instance ToJSON AttributeUpdates where
80- toJSON = object . map mk
91+ toJSON = object . map mk . getAttributeUpdates
8192 where
8293 mk AttributeUpdate { auAction = UDelete , auAttr = auAttr } =
8394 (attrName auAttr) .= object
@@ -114,7 +125,7 @@ instance ToJSON UpdateItem where
114125 object $ expectsJson uiExpect ++
115126 [ " TableName" .= uiTable
116127 , " Key" .= uiKey
117- , " AttributeUpdates" .= uiUpdates
128+ , " AttributeUpdates" .= AttributeUpdates uiUpdates
118129 , " ReturnValues" .= uiReturn
119130 , " ReturnConsumedCapacity" .= uiRetCons
120131 , " ReturnItemCollectionMetrics" .= uiRetMet
0 commit comments