diff --git a/src/PostgREST/Query/QueryBuilder.hs b/src/PostgREST/Query/QueryBuilder.hs index dc96b4fef..96701be25 100644 --- a/src/PostgREST/Query/QueryBuilder.hs +++ b/src/PostgREST/Query/QueryBuilder.hs @@ -111,7 +111,7 @@ getJoin fld node@(Node ReadPlan{relJoinType} _) = in correlatedSubquery subq aggAlias condition mutatePlanToQuery :: MutatePlan -> SQL.Snippet -mutatePlanToQuery (Insert mainQi iCols body onConflct putConditions returnings _ applyDefaults) = +mutatePlanToQuery (Insert mainQi iCols body onConflict putConditions returnings _ applyDefaults) = "INSERT INTO " <> fromQi mainQi <> (if null iCols then " " else "(" <> cols <> ") ") <> fromJsonBodyF body iCols True False applyDefaults <> -- Only used for PUT @@ -128,11 +128,11 @@ mutatePlanToQuery (Insert mainQi iCols body onConflct putConditions returnings _ if null iCols then "DO NOTHING" else "DO UPDATE SET " <> intercalateSnippet ", " ((pgFmtIdent . cfName) <> const " = EXCLUDED." <> (pgFmtIdent . cfName) <$> iCols) <> (if null putConditions && not mergeDups then mempty else "WHERE " <> addConfigPgrstInserted False) - ) onConflct <> " " <> + ) onConflict <> " " <> returningF mainQi returnings where cols = intercalateSnippet ", " $ pgFmtIdent . cfName <$> iCols - mergeDups = case onConflct of {Just (MergeDuplicates,_) -> True; _ -> False;} + mergeDups = case onConflict of {Just (MergeDuplicates,_) -> True; _ -> False;} -- An update without a limit is always filtered with a WHERE mutatePlanToQuery (Update mainQi uCols body logicForest range ordts returnings applyDefaults)