mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
server: trivial refactor in postgres insert
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3746 GitOrigin-RevId: 3d3004862bb64bef55d2716f4c2a86f95343cab5
This commit is contained in:
parent
ad7ecc8ed5
commit
b74ed10cb5
@ -145,7 +145,7 @@ insertObject singleObjIns additionalColumns userInfo planVars stringifyNum = Tra
|
|||||||
objRelDeterminedCols = concatMap snd objInsRes
|
objRelDeterminedCols = concatMap snd objInsRes
|
||||||
finalInsCols = columns <> objRelDeterminedCols <> additionalColumns
|
finalInsCols = columns <> objRelDeterminedCols <> additionalColumns
|
||||||
|
|
||||||
cte <- mkInsertQ table onConflict finalInsCols defaultValues checkCond
|
let cte = mkInsertQ table onConflict finalInsCols defaultValues checkCond
|
||||||
|
|
||||||
PGE.MutateResp affRows colVals <-
|
PGE.MutateResp affRows colVals <-
|
||||||
liftTx $
|
liftTx $
|
||||||
@ -304,14 +304,14 @@ validateInsert insCols objRels addCols = do
|
|||||||
insConflictCols = insCols `intersect` addCols
|
insConflictCols = insCols `intersect` addCols
|
||||||
|
|
||||||
mkInsertQ ::
|
mkInsertQ ::
|
||||||
(MonadError QErr m, Backend ('Postgres pgKind)) =>
|
Backend ('Postgres pgKind) =>
|
||||||
QualifiedTable ->
|
QualifiedTable ->
|
||||||
Maybe (IR.OnConflictClause ('Postgres pgKind) PG.SQLExp) ->
|
Maybe (IR.OnConflictClause ('Postgres pgKind) PG.SQLExp) ->
|
||||||
[(PGCol, PG.SQLExp)] ->
|
[(PGCol, PG.SQLExp)] ->
|
||||||
Map.HashMap PGCol PG.SQLExp ->
|
Map.HashMap PGCol PG.SQLExp ->
|
||||||
(AnnBoolExpSQL ('Postgres pgKind), Maybe (AnnBoolExpSQL ('Postgres pgKind))) ->
|
(AnnBoolExpSQL ('Postgres pgKind), Maybe (AnnBoolExpSQL ('Postgres pgKind))) ->
|
||||||
m PG.CTE
|
PG.CTE
|
||||||
mkInsertQ table onConflictM insCols defVals (insCheck, updCheck) = do
|
mkInsertQ table onConflictM insCols defVals (insCheck, updCheck) =
|
||||||
let sqlConflict = PGT.toSQLConflict table <$> onConflictM
|
let sqlConflict = PGT.toSQLConflict table <$> onConflictM
|
||||||
sqlExps = mkSQLRow defVals insCols
|
sqlExps = mkSQLRow defVals insCols
|
||||||
valueExp = PG.ValuesExp [PG.TupleExp sqlExps]
|
valueExp = PG.ValuesExp [PG.TupleExp sqlExps]
|
||||||
@ -327,7 +327,7 @@ mkInsertQ table onConflictM insCols defVals (insCheck, updCheck) = do
|
|||||||
(PGT.toSQLBoolExp (PG.QualTable table) insCheck)
|
(PGT.toSQLBoolExp (PG.QualTable table) insCheck)
|
||||||
(fmap (PGT.toSQLBoolExp (PG.QualTable table)) updCheck)
|
(fmap (PGT.toSQLBoolExp (PG.QualTable table)) updCheck)
|
||||||
]
|
]
|
||||||
pure $ PG.CTEInsert sqlInsert
|
in PG.CTEInsert sqlInsert
|
||||||
|
|
||||||
fetchFromColVals ::
|
fetchFromColVals ::
|
||||||
MonadError QErr m =>
|
MonadError QErr m =>
|
||||||
|
Loading…
Reference in New Issue
Block a user