From b74ed10cb5a0da43d689cb30fb4dbe6de0cba5ad Mon Sep 17 00:00:00 2001 From: Evie Ciobanu <1017953+eviefp@users.noreply.github.com> Date: Mon, 21 Feb 2022 20:21:36 +0200 Subject: [PATCH] server: trivial refactor in postgres insert PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3746 GitOrigin-RevId: 3d3004862bb64bef55d2716f4c2a86f95343cab5 --- .../src-lib/Hasura/Backends/Postgres/Execute/Insert.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src-lib/Hasura/Backends/Postgres/Execute/Insert.hs b/server/src-lib/Hasura/Backends/Postgres/Execute/Insert.hs index 745000c79a7..0be50fa29ce 100644 --- a/server/src-lib/Hasura/Backends/Postgres/Execute/Insert.hs +++ b/server/src-lib/Hasura/Backends/Postgres/Execute/Insert.hs @@ -145,7 +145,7 @@ insertObject singleObjIns additionalColumns userInfo planVars stringifyNum = Tra objRelDeterminedCols = concatMap snd objInsRes finalInsCols = columns <> objRelDeterminedCols <> additionalColumns - cte <- mkInsertQ table onConflict finalInsCols defaultValues checkCond + let cte = mkInsertQ table onConflict finalInsCols defaultValues checkCond PGE.MutateResp affRows colVals <- liftTx $ @@ -304,14 +304,14 @@ validateInsert insCols objRels addCols = do insConflictCols = insCols `intersect` addCols mkInsertQ :: - (MonadError QErr m, Backend ('Postgres pgKind)) => + Backend ('Postgres pgKind) => QualifiedTable -> Maybe (IR.OnConflictClause ('Postgres pgKind) PG.SQLExp) -> [(PGCol, PG.SQLExp)] -> Map.HashMap PGCol PG.SQLExp -> (AnnBoolExpSQL ('Postgres pgKind), Maybe (AnnBoolExpSQL ('Postgres pgKind))) -> - m PG.CTE -mkInsertQ table onConflictM insCols defVals (insCheck, updCheck) = do + PG.CTE +mkInsertQ table onConflictM insCols defVals (insCheck, updCheck) = let sqlConflict = PGT.toSQLConflict table <$> onConflictM sqlExps = mkSQLRow defVals insCols valueExp = PG.ValuesExp [PG.TupleExp sqlExps] @@ -327,7 +327,7 @@ mkInsertQ table onConflictM insCols defVals (insCheck, updCheck) = do (PGT.toSQLBoolExp (PG.QualTable table) insCheck) (fmap (PGT.toSQLBoolExp (PG.QualTable table)) updCheck) ] - pure $ PG.CTEInsert sqlInsert + in PG.CTEInsert sqlInsert fetchFromColVals :: MonadError QErr m =>