2021-12-09 12:05:42 +03:00
|
|
|
module Hasura.RQL.IR.Conflict
|
2021-12-20 14:15:51 +03:00
|
|
|
( OnConflictClause (..),
|
|
|
|
OnConflictClauseData (..),
|
2021-12-09 12:05:42 +03:00
|
|
|
ConflictTarget (..),
|
|
|
|
)
|
|
|
|
where
|
|
|
|
|
|
|
|
import Hasura.Prelude
|
|
|
|
import Hasura.RQL.IR.BoolExp
|
|
|
|
import Hasura.RQL.Types.Backend
|
2023-04-24 21:35:48 +03:00
|
|
|
import Hasura.RQL.Types.BackendType
|
2021-12-09 12:05:42 +03:00
|
|
|
|
2021-12-20 14:15:51 +03:00
|
|
|
-- 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.
|
|
|
|
|
2021-12-09 12:05:42 +03:00
|
|
|
data ConflictTarget (b :: BackendType)
|
|
|
|
= CTColumn [Column b]
|
|
|
|
| CTConstraint (ConstraintName b)
|
|
|
|
|
2023-05-24 16:51:56 +03:00
|
|
|
deriving instance (Backend b) => Show (ConflictTarget b)
|
2021-12-09 12:05:42 +03:00
|
|
|
|
2023-05-24 16:51:56 +03:00
|
|
|
deriving instance (Backend b) => Eq (ConflictTarget b)
|
2021-12-09 12:05:42 +03:00
|
|
|
|
2021-12-20 14:15:51 +03:00
|
|
|
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)
|
2021-12-09 12:05:42 +03:00
|
|
|
deriving (Functor, Foldable, Traversable)
|