Upsert with "Prefer: resolution=merge-duplicates" on specified columns (#1327) (#1432)

Allow query param 'on_conflict=key1,key2,...' to upsert with explicit columns with unique
constraint.
This commit is contained in:
YUKISHITA Yohsuke
2019-12-29 11:52:58 -05:00
committed by Steve Chavez
parent e12c1319b6
commit 99b13fa25f
10 changed files with 91 additions and 2 deletions
+5 -1
View File
@@ -324,7 +324,11 @@ addProperty f (targetNodeName:remainingPath, a) (Node rn forest) =
mutateRequest :: Schema -> TableName -> ApiRequest -> S.Set FieldName -> [FieldName] -> ReadRequest -> Either Response MutateRequest
mutateRequest schema tName apiRequest cols pkCols readReq = mapLeft errorResponseFor $
case action of
ActionCreate -> Right $ Insert qi cols ((,) <$> iPreferResolution apiRequest <*> Just pkCols) [] returnings
ActionCreate -> do
confCols <- case iOnConflict apiRequest of
Nothing -> pure pkCols
Just param -> pRequestOnConflict param
pure $ Insert qi cols ((,) <$> iPreferResolution apiRequest <*> Just confCols) [] returnings
ActionUpdate -> Update qi cols <$> combinedLogic <*> pure returnings
ActionSingleUpsert ->
(\flts ->