on master help sign in
Rename Insertion constructor to Value
63c5e03Shane O'Brien
src/Rel8/Column/Field.hs+4−4
@@ -88,10 +88,10 @@ sfromColumn = \case
88 SExpr -> \_ (E a) -> AField a
88 SExpr -> \_ (E a) -> AField a
89 SInsert -> \case
89 SInsert -> \case
90 SRequired -> \case
90 SRequired -> \case
91− I (Insertion a) -> AField a
91+ I (Value a) -> AField a
92 SOptional -> \case
92 SOptional -> \case
93 I Default -> AField Nothing
93 I Default -> AField Nothing
94− I (Insertion a) -> AField (Just a)
94+ I (Value a) -> AField (Just a)
95 SName -> \_ (N a) -> AField a
95 SName -> \_ (N a) -> AField a
96 SResult -> \_ (R a) -> AField a
96 SResult -> \_ (R a) -> AField a
97 SReify context ->
97 SReify context ->
@@ -107,8 +107,8 @@ stoColumn = \case
107 SAggregate -> \_ (AField a) -> A a
107 SAggregate -> \_ (AField a) -> A a
108 SExpr -> \_ (AField a) -> E a
108 SExpr -> \_ (AField a) -> E a
109 SInsert -> \case
109 SInsert -> \case
110− SRequired -> \(AField a) -> I (Insertion a)
110+ SRequired -> \(AField a) -> I (Value a)
111− SOptional -> \(AField ma) -> I $ maybe Default Insertion ma
111+ SOptional -> \(AField ma) -> I $ maybe Default Value ma
112 SName -> \_ (AField a) -> N a
112 SName -> \_ (AField a) -> N a
113 SResult -> \_ (AField a) -> R a
113 SResult -> \_ (AField a) -> R a
114 SReify context ->
114 SReify context ->
src/Rel8/Generic/Construction.hs+3−3
@@ -189,13 +189,13 @@ gginsert gfromColumns = case algebraSing @algebra of
189 @name
189 @name
190 @(Eval (rep (Reify Insert)))
190 @(Eval (rep (Reify Insert)))
191 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
191 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
192− (\SSpec {info} -> Reify $ I (Insertion (snull info)))
192+ (\SSpec {info} -> Reify $ I (Value (snull info)))
193 (\SSpec {nullity} -> case nullity of
193 (\SSpec {nullity} -> case nullity of
194 Null -> id
194 Null -> id
195 NotNull -> \case
195 NotNull -> \case
196 Reify (I Default) -> Reify (I Default)
196 Reify (I Default) -> Reify (I Default)
197− Reify (I (Insertion a)) -> Reify (I (Insertion (nullify a))))
197+ Reify (I (Value a)) -> Reify (I (Value (nullify a))))
198− (HType . Reify . I . Insertion . litExpr)
198+ (HType . Reify . I . Value . litExpr)
199
199
200
200
201type GGConstructable :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Constraint
201type GGConstructable :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Constraint
src/Rel8/Schema/Insert.hs+5−6
@@ -85,7 +85,7 @@ instance Interpretation Insert where
85type Insertion :: Necessity -> Type -> Type
85type Insertion :: Necessity -> Type -> Type
86data Insertion necessity a where
86data Insertion necessity a where
87 Default :: Insertion 'Optional a
87 Default :: Insertion 'Optional a
88− Insertion :: Expr a -> Insertion necessity a
88+ Value :: Expr a -> Insertion necessity a
89
89
90
90
91instance (KnownNecessity necessity, Sql DBType a) =>
91instance (KnownNecessity necessity, Sql DBType a) =>
@@ -137,20 +137,19 @@ instance Labelable Insert where
137
137
138
138
139instance Nullifiable Insert where
139instance Nullifiable Insert where
140− encodeTag = I . Insertion . expr
140+ encodeTag = I . Value . expr
141
141
142− decodeTag (I (Insertion a)) = fromExpr a
142+ decodeTag (I (Value a)) = fromExpr a
143
143
144 nullifier Tag {expr} test SSpec {nullity} = \case
144 nullifier Tag {expr} test SSpec {nullity} = \case
145 I Default -> I Default
145 I Default -> I Default
146− I (Insertion a) ->
147− I $ Insertion $ runTag nullity condition a
146+ I (Value a) -> I $ Value $ runTag nullity condition a
148 where
147 where
149 condition = test expr
148 condition = test expr
150
149
151 unnullifier SSpec {nullity} = \case
150 unnullifier SSpec {nullity} = \case
152 I Default -> I Default
151 I Default -> I Default
153− I (Insertion a) -> I $ Insertion $ unnull nullity a
152+ I (Value a) -> I $ Value $ unnull nullity a
154
153
155 {-# INLINABLE encodeTag #-}
154 {-# INLINABLE encodeTag #-}
156 {-# INLINABLE decodeTag #-}
155 {-# INLINABLE decodeTag #-}
src/Rel8/Table/Insert.hs+2−2
@@ -29,7 +29,7 @@ toInsert :: Inserts exprs inserts => exprs -> inserts
29toInsert (toColumns -> exprs) = fromColumns $ htabulate $ \field ->
29toInsert (toColumns -> exprs) = fromColumns $ htabulate $ \field ->
30 case hfield hspecs field of
30 case hfield hspecs field of
31 SSpec {} -> I $ case hfield exprs field of
31 SSpec {} -> I $ case hfield exprs field of
32− E expr -> Insertion expr
32+ E expr -> Value expr
33
33
34
34
35-- | @toInsertDefaults@ converts a 'Table' of 'Expr's into a 'Table' that can
35-- | @toInsertDefaults@ converts a 'Table' of 'Expr's into a 'Table' that can
@@ -45,5 +45,5 @@ toInsertDefaults (toColumns -> exprs) = fromColumns $ htabulate $ \field ->
45 case hfield hspecs field of
45 case hfield hspecs field of
46 SSpec {necessity} -> case hfield exprs field of
46 SSpec {necessity} -> case hfield exprs field of
47 E expr -> I $ case necessity of
47 E expr -> I $ case necessity of
48− SRequired -> Insertion expr
48+ SRequired -> Value expr
49 SOptional -> Default
49 SOptional -> Default
src/Rel8/Table/Opaleye.hs+2−2
@@ -99,7 +99,7 @@ tableFields (toColumns -> names) = dimap toColumns fromColumns $
99 go :: SSpec spec -> Col Name spec -> Opaleye.TableFields (Col Insert spec) (Col Expr spec)
99 go :: SSpec spec -> Col Name spec -> Opaleye.TableFields (Col Insert spec) (Col Expr spec)
100 go SSpec {necessity} (N (Name name)) = case necessity of
100 go SSpec {necessity} (N (Name name)) = case necessity of
101 SRequired ->
101 SRequired ->
102− lmap (\(I (Insertion a)) -> toColumn $ toPrimExpr a) $
102+ lmap (\(I (Value a)) -> toColumn $ toPrimExpr a) $
103 E . fromPrimExpr . fromColumn <$>
103 E . fromPrimExpr . fromColumn <$>
104 Opaleye.requiredTableField name
104 Opaleye.requiredTableField name
105 SOptional ->
105 SOptional ->
@@ -109,7 +109,7 @@ tableFields (toColumns -> names) = dimap toColumns fromColumns $
109 where
109 where
110 fromInsert = \case
110 fromInsert = \case
111 Default -> Nothing
111 Default -> Nothing
112− Insertion a -> Just a
112+ Value a -> Just a
113
113
114
114
115unpackspec :: Table Expr a => Opaleye.Unpackspec a a
115unpackspec :: Table Expr a => Opaleye.Unpackspec a a