Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Internal representation of an insertion in a database table.
What makes this specific mutation tricky is that we support recursive insertions, across local relationships. Because local joins come in two different kinds (object relationships and array relations), and because for each table we expose two root different root fields (insert_one and insert), we distinguish between *single row inserts* and *multi rows inserts*.
TODO: the distinction between single-row inserts and multi-rows inserts does not need to be enforced the way it currently is, with booleans and different types. The distinction could be made in the translation layer, if need be.
Synopsis
- data AnnotatedInsert (b :: BackendType) (r :: Type) v = AnnotatedInsert {
- _aiFieldName :: Text
- _aiIsSingle :: Bool
- _aiData :: MultiObjectInsert b v
- _aiOutput :: MutationOutputG b r v
- _aiNamingConvention :: Maybe NamingCase
- data AnnotatedInsertData (b :: BackendType) (f :: Type -> Type) (v :: Type) = AnnotatedInsertData {
- _aiInsertObject :: f (AnnotatedInsertRow b v)
- _aiTableName :: TableName b
- _aiCheckCondition :: (AnnBoolExp b v, Maybe (AnnBoolExp b v))
- _aiTableColumns :: [ColumnInfo b]
- _aiPrimaryKey :: Maybe (NESeq (Column b))
- _aiExtraTableMetadata :: ExtraTableMetadata b
- _aiPresetValues :: PreSetColsG b v
- _aiBackendInsert :: BackendInsert b v
- _aiValidateInput :: Maybe (ValidateInput ResolvedWebhook)
- newtype Single a = Single {
- unSingle :: a
- type SingleObjectInsert b v = AnnotatedInsertData b Single v
- type MultiObjectInsert b v = AnnotatedInsertData b [] v
- data AnnotatedInsertField (b :: BackendType) v
- = AIColumn (Column b, v)
- | AIObjectRelationship (XNestedInserts b) (ObjectRelationInsert b v)
- | AIArrayRelationship (XNestedInserts b) (ArrayRelationInsert b v)
- type AnnotatedInsertRow b v = [AnnotatedInsertField b v]
- data RelationInsert (b :: BackendType) a = RelationInsert {
- _riInsertData :: a
- _riRelationInfo :: RelInfo b
- type ObjectRelationInsert b v = RelationInsert b (SingleObjectInsert b v)
- type ArrayRelationInsert b v = RelationInsert b (MultiObjectInsert b v)
- data InsertQueryP1 (b :: BackendType) = InsertQueryP1 {
- iqp1Table :: TableName b
- iqp1Cols :: [Column b]
- iqp1Tuples :: [[SQLExpression b]]
- iqp1Conflict :: Maybe (OnConflictClause b (SQLExpression b))
- iqp1CheckCond :: (AnnBoolExpSQL b, Maybe (AnnBoolExpSQL b))
- iqp1Output :: MutationOutput b
- iqp1AllCols :: [ColumnInfo b]
- aiOutput :: forall b r v r. Lens (AnnotatedInsert b r v) (AnnotatedInsert b r v) (MutationOutputG b r v) (MutationOutputG b r v)
- aiNamingConvention :: forall b r v. Lens' (AnnotatedInsert b r v) (Maybe NamingCase)
- aiIsSingle :: forall b r v. Lens' (AnnotatedInsert b r v) Bool
- aiFieldName :: forall b r v. Lens' (AnnotatedInsert b r v) Text
- aiData :: forall b r v. Lens' (AnnotatedInsert b r v) (MultiObjectInsert b v)
- _AIArrayRelationship :: forall b v. Prism' (AnnotatedInsertField b v) (XNestedInserts b, ArrayRelationInsert b v)
- _AIObjectRelationship :: forall b v. Prism' (AnnotatedInsertField b v) (XNestedInserts b, ObjectRelationInsert b v)
- _AIColumn :: forall b v. Prism' (AnnotatedInsertField b v) (Column b, v)
- getInsertColumns :: AnnotatedInsertRow b v -> [(Column b, v)]
- getInsertObjectRelationships :: AnnotatedInsertRow b v -> [ObjectRelationInsert b v]
- getInsertArrayRelationships :: AnnotatedInsertRow b v -> [ArrayRelationInsert b v]
Documentation
data AnnotatedInsert (b :: BackendType) (r :: Type) v Source #
Overall representation of an insert mutation, corresponding to one root
field in our mutation, including the parsed selection set of the mutation's
output. For historical reasons, it will always contain a MultiObjectInsert
,
whether the root mutation is a single row or not, and will distinguish
between them using a boolean field.
AnnotatedInsert | |
|
Instances
data AnnotatedInsertData (b :: BackendType) (f :: Type -> Type) (v :: Type) Source #
One individual insert, one node from the tree.
The f
parameter is used to construct the container for the values to be
inserted: Single
for a single-row insert, '[]' for a multi-row insert.
AnnotatedInsertData | |
|
Instances
Ad-hoc helper.
We differientate between single row inserts (SingleObjIns
) and multiple row
inserts (MultiObjIns
), but both use the same underlying representation:
AnnIns
. The only difference is which functor is used as a parameter. We use
'[]' for MultiObjIns
, and we use this trivial Single
for SingleObjIns
.
Instances
Foldable Single Source # | |
Defined in Hasura.RQL.IR.Insert fold :: Monoid m => Single m -> m # foldMap :: Monoid m => (a -> m) -> Single a -> m # foldMap' :: Monoid m => (a -> m) -> Single a -> m # foldr :: (a -> b -> b) -> b -> Single a -> b # foldr' :: (a -> b -> b) -> b -> Single a -> b # foldl :: (b -> a -> b) -> b -> Single a -> b # foldl' :: (b -> a -> b) -> b -> Single a -> b # foldr1 :: (a -> a -> a) -> Single a -> a # foldl1 :: (a -> a -> a) -> Single a -> a # elem :: Eq a => a -> Single a -> Bool # maximum :: Ord a => Single a -> a # minimum :: Ord a => Single a -> a # | |
Traversable Single Source # | |
Functor Single Source # | |
type SingleObjectInsert b v = AnnotatedInsertData b Single v Source #
type MultiObjectInsert b v = AnnotatedInsertData b [] v Source #
data AnnotatedInsertField (b :: BackendType) v Source #
An insert item. The object and array relationships are not unavailable when 'XNestedInserts b = XDisable'
AIColumn (Column b, v) | |
AIObjectRelationship (XNestedInserts b) (ObjectRelationInsert b v) | |
AIArrayRelationship (XNestedInserts b) (ArrayRelationInsert b v) |
Instances
type AnnotatedInsertRow b v = [AnnotatedInsertField b v] Source #
One individual row to be inserted. Contains the columns' values and all the matching recursive relationship inserts.
data RelationInsert (b :: BackendType) a Source #
One individual relationship.
Unlike other types, this one is not parameterized by the type of the leaves
v
, but by the kind of insert has to be performed: multi-row or single row.
See ObjectRelationInsert
and ArrayRelationInsert
.
RelationInsert | |
|
Instances
type ObjectRelationInsert b v = RelationInsert b (SingleObjectInsert b v) Source #
Insert across an object relationship.
Object relationships are 1:1 relationships across tables; an insert across
such a relationship can only insert one single row at a time; RelIns
is
therefore parameterized by a SingleObjectInsert
.
type ArrayRelationInsert b v = RelationInsert b (MultiObjectInsert b v) Source #
Insert across an array relationship.
Array relationships are 1:* relationships across tables; an insert across
such a relationship may therefore contain multiple rows; RelIns
is
therefore parameterized by a MultiObjectInsert
.
data InsertQueryP1 (b :: BackendType) Source #
Old-style representation used for non-recursive insertions. This is the representation used by RQL.DML, instead of the new fancy recursive one present in this file. Postgres supports both representations, and actually translates recursive queries that do not have any relationships into this representation first.
InsertQueryP1 | |
|
aiOutput :: forall b r v r. Lens (AnnotatedInsert b r v) (AnnotatedInsert b r v) (MutationOutputG b r v) (MutationOutputG b r v) Source #
aiNamingConvention :: forall b r v. Lens' (AnnotatedInsert b r v) (Maybe NamingCase) Source #
aiIsSingle :: forall b r v. Lens' (AnnotatedInsert b r v) Bool Source #
aiFieldName :: forall b r v. Lens' (AnnotatedInsert b r v) Text Source #
aiData :: forall b r v. Lens' (AnnotatedInsert b r v) (MultiObjectInsert b v) Source #
_AIArrayRelationship :: forall b v. Prism' (AnnotatedInsertField b v) (XNestedInserts b, ArrayRelationInsert b v) Source #
_AIObjectRelationship :: forall b v. Prism' (AnnotatedInsertField b v) (XNestedInserts b, ObjectRelationInsert b v) Source #
getInsertColumns :: AnnotatedInsertRow b v -> [(Column b, v)] Source #
getInsertObjectRelationships :: AnnotatedInsertRow b v -> [ObjectRelationInsert b v] Source #
getInsertArrayRelationships :: AnnotatedInsertRow b v -> [ArrayRelationInsert b v] Source #