graphql-engine/server/src-lib/Hasura/RQL/IR/Conflict.hs
Evie Ciobanu 974113c80e server: Improve code readability around OnConflict clauses
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3181
GitOrigin-RevId: 0ded0f2776fcbaaf51420f796673cf132b8cc248
2021-12-20 11:16:46 +00:00

37 lines
1.0 KiB
Haskell

module Hasura.RQL.IR.Conflict
( OnConflictClause (..),
OnConflictClauseData (..),
ConflictTarget (..),
)
where
import Hasura.Prelude
import Hasura.RQL.IR.BoolExp
import Hasura.RQL.Types.Backend
import Hasura.SQL.Backend
-- TODO: When adding support for other backends, consider whether these types
-- really are generic. If not, please start by moving them to a Postgres-specific
-- module.
data ConflictTarget (b :: BackendType)
= CTColumn [Column b]
| CTConstraint (ConstraintName b)
deriving instance Backend b => Show (ConflictTarget b)
deriving instance Backend b => Eq (ConflictTarget b)
data OnConflictClauseData b v = OnConflictClauseData
{ cp1udConflictTarget :: ConflictTarget b,
cp1udAffectedColumns :: [Column b],
cp1udValues :: PreSetColsG b v,
cp1udFilter :: AnnBoolExp b v
}
deriving (Functor, Foldable, Traversable)
data OnConflictClause (b :: BackendType) v
= OCCDoNothing (Maybe (ConflictTarget b))
| OCCUpdate (OnConflictClauseData b v)
deriving (Functor, Foldable, Traversable)