1{-# language FlexibleContexts #-}
2{-# language NamedFieldPuns #-}
3{-# language TypeFamilies #-}
4{-# language ViewPatterns #-}
6module Rel8.Table.Insert
16import Rel8.Kind.Necessity ( SNecessity( SOptional, SRequired ) )
17import Rel8.Schema.Context ( Col'(..) )
18import Rel8.Schema.HTable ( hfield, htabulate, hspecs )
19import Rel8.Schema.Spec ( SSpec(..) )
20import Rel8.Table ( fromColumns, toColumns )
21import Rel8.Table.Recontextualize ( Inserts )
24toInsert :: Inserts exprs inserts => exprs -> inserts
25toInsert (toColumns -> exprs) = fromColumns $ htabulate $ \field ->
26 case hfield hspecs field of
27 SSpec {necessity} -> case hfield exprs field of
28 DB expr -> case necessity of
29 SRequired -> RequiredInsert expr
30 SOptional -> OptionalInsert (Just expr)
33toInsertDefaults :: Inserts exprs inserts => exprs -> inserts
34toInsertDefaults (toColumns -> exprs) = fromColumns $ htabulate $ \field ->
35 case hfield hspecs field of
36 SSpec {necessity} -> case hfield exprs field of
37 DB expr -> case necessity of
38 SRequired -> RequiredInsert expr
39 SOptional -> OptionalInsert Nothing
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list