on dev help sign in
rename types
commit2c6ec5ce3a4fc0a9b918d271831ecb6341d65ba9 authorEitan Chatav <eitan.chatav@gmail.com> dateSun 13 Aug 2017, 10:58 (9 years ago) parentf258d52
7 files changed+208−381
squeel-postgresql/exe/Example.hs+7−7 squeel-postgresql/squeel-postgresql.cabal−1 squeel-postgresql/src/Squeel/PostgreSQL/Binary.hs−145 squeel-postgresql/src/Squeel/PostgreSQL/Binary2.hs+47−47 squeel-postgresql/src/Squeel/PostgreSQL/Schema.hs+38−56 squeel-postgresql/src/Squeel/PostgreSQL/Statement.hs+87−101 squeel-postgresql/test/Squeel/PostgreSQL/StatementSpec.hs+29−24
squeel-postgresql/exe/Example.hs+7−7
@@ -39,10 +39,10 @@ main = do
3939 connection2 <- runPQ (connection1 :: Connection Schema) $ do
4040 let
4141 manipulation :: Manipulation Schema
42− '[ 'Required ('NotNull 'PGInt4)
43− , 'Required ('NotNull 'PGInt4)
44− , 'Required ('NotNull 'PGInt4)
45− , 'Required ('NotNull 'PGInt4)
42+ '[ 'Required ('NotNull 'PGint4)
43+ , 'Required ('NotNull 'PGint4)
44+ , 'Required ('NotNull 'PGint4)
45+ , 'Required ('NotNull 'PGint4)
4646 ] '[]
4747 manipulation =
4848 insertInto #table1
@@ -78,9 +78,9 @@ data Table1Row = Table1Row { col1 :: Int32, col2 :: Int32 }
7878instance Generic Table1Row
7979
8080type Schema =
81− '[ "students" ::: '["name" ::: 'Required ('NotNull 'PGText)]
81+ '[ "students" ::: '["name" ::: 'Required ('NotNull 'PGtext)]
8282 , "table1" :::
83− '[ "col1" ::: 'Required ('NotNull 'PGInt4)
84− , "col2" ::: 'Required ('NotNull 'PGInt4)
83+ '[ "col1" ::: 'Required ('NotNull 'PGint4)
84+ , "col2" ::: 'Required ('NotNull 'PGint4)
8585 ]
8686 ]
squeel-postgresql/squeel-postgresql.cabal−1
@@ -14,7 +14,6 @@ library
1414 hs-source-dirs: src
1515 exposed-modules:
1616 Squeel.PostgreSQL
17− Squeel.PostgreSQL.Binary
1817 Squeel.PostgreSQL.Binary2
1918 Squeel.PostgreSQL.PQ
2019 Squeel.PostgreSQL.Statement
squeel-postgresql/src/Squeel/PostgreSQL/Binary.hsdeleted−145
@@ -1,145 +0,0 @@
1−{-# LANGUAGE
2− DataKinds
3− , FlexibleContexts
4− , FlexibleInstances
5− , GADTs
6− , LambdaCase
7− , MagicHash
8− , MultiParamTypeClasses
9− , PolyKinds
10− , ScopedTypeVariables
11− , TypeOperators
12−#-}
13−
14−module Squeel.PostgreSQL.Binary where
15−
16−import Data.ByteString (ByteString)
17−import Data.Int (Int16,Int32,Int64)
18−import Generics.SOP
19−import Data.Scientific (Scientific)
20−import Data.Text (Text)
21−import Data.Time (Day, TimeOfDay, TimeZone, LocalTime, UTCTime, DiffTime)
22−import Data.UUID (UUID)
23−
24−import qualified Data.Aeson as Aeson
25−import qualified Data.ByteString.Lazy as Lazy (ByteString)
26−import qualified Data.Text.Lazy as Lazy (Text)
27−import qualified PostgreSQL.Binary.Decoding as Decoder
28−import qualified PostgreSQL.Binary.Encoding as Encoder
29−
30−import Squeel.PostgreSQL.Schema
31−
32−decodeValue :: HasDecoding pg x => proxy pg -> ByteString -> Either Text x
33−decodeValue p = Decoder.valueParser $ decoding p
34−
35−class HasDecoding pg x where
36− decoding :: proxy pg -> Decoder.Value x
37−instance HasDecoding (column ::: 'Required ('NotNull 'PGInt2)) Int16 where
38− decoding _ = Decoder.int
39−instance HasDecoding (column ::: 'Required ('NotNull 'PGInt4)) Int32 where
40− decoding _ = Decoder.int
41−instance HasDecoding (column ::: 'Required ('NotNull 'PGInt8)) Int64 where
42− decoding _ = Decoder.int
43−instance HasDecoding (column ::: 'Required ('NotNull 'PGFloat4)) Float where
44− decoding _ = Decoder.float4
45−instance HasDecoding (column ::: 'Required ('NotNull 'PGFloat8)) Double where
46− decoding _ = Decoder.float8
47−instance HasDecoding (column ::: 'Required ('NotNull 'PGBool)) Bool where
48− decoding _ = Decoder.bool
49−instance HasDecoding (column ::: 'Required ('NotNull 'PGBytea)) ByteString where
50− decoding _ = Decoder.bytea_strict
51−instance HasDecoding (column ::: 'Required ('NotNull 'PGBytea)) Lazy.ByteString where
52− decoding _ = Decoder.bytea_lazy
53−instance HasDecoding (column ::: 'Required ('NotNull 'PGText)) Text where
54− decoding _ = Decoder.text_strict
55−instance HasDecoding (column ::: 'Required ('NotNull 'PGText)) Lazy.Text where
56− decoding _ = Decoder.text_lazy
57−instance HasDecoding (column ::: 'Required ('NotNull ('PGChar 1))) Char where
58− decoding _ = Decoder.char
59−instance HasDecoding (column ::: 'Required ('NotNull 'PGNumeric)) Scientific where
60− decoding _ = Decoder.numeric
61−instance HasDecoding (column ::: 'Required ('NotNull 'PGUuid)) UUID where
62− decoding _ = Decoder.uuid
63−instance HasDecoding (column ::: 'Required ('NotNull 'PGJson)) Aeson.Value where
64− decoding _ = Decoder.json_ast
65−instance HasDecoding (column ::: 'Required ('NotNull 'PGJsonb)) Aeson.Value where
66− decoding _ = Decoder.jsonb_ast
67−instance HasDecoding (column ::: 'Required ('NotNull 'PGDate)) Day where
68− decoding _ = Decoder.date
69−instance HasDecoding (column ::: 'Required ('NotNull 'PGTime)) TimeOfDay where
70− decoding _ = Decoder.time_int
71−instance HasDecoding (column ::: 'Required ('NotNull 'PGTimeTZ)) (TimeOfDay, TimeZone) where
72− decoding _ = Decoder.timetz_int
73−instance HasDecoding (column ::: 'Required ('NotNull 'PGTimestamp)) LocalTime where
74− decoding _ = Decoder.timestamp_int
75−instance HasDecoding (column ::: 'Required ('NotNull 'PGTimestampTZ)) UTCTime where
76− decoding _ = Decoder.timestamptz_int
77−instance HasDecoding (column ::: 'Required ('NotNull 'PGInterval)) DiffTime where
78− decoding _ = Decoder.interval_int
79−
80−decodings
81− :: AllZip HasDecoding pgs xs
82− => proxy pgs
83− -> NP (K ByteString) xs -> Either Text (NP I xs)
84−decodings _ Nil = return Nil
85−decodings (_ :: proxy pgs) (K bytestring :* bytestrings) =
86− case (hpure Proxy :: NP Proxy pgs) of
87− proxy :* proxies -> (:*)
88− <$> (I <$> Decoder.valueParser (decoding proxy) bytestring)
89− <*> decodings proxies bytestrings
90−
91−class HasEncoding pg x where
92− encoding :: proxy pg -> x -> Encoder.Encoding
93−instance HasEncoding ('Required ('NotNull 'PGInt2)) Int16 where
94− encoding _ = Encoder.int2_int16
95−instance HasEncoding ('Required ('NotNull 'PGInt4)) Int32 where
96− encoding _ = Encoder.int4_int32
97−instance HasEncoding ('Required ('NotNull 'PGInt8)) Int64 where
98− encoding _ = Encoder.int8_int64
99−instance HasEncoding ('Required ('NotNull 'PGFloat4)) Float where
100− encoding _ = Encoder.float4
101−instance HasEncoding ('Required ('NotNull 'PGFloat8)) Double where
102− encoding _ = Encoder.float8
103−instance HasEncoding ('Required ('NotNull 'PGBool)) Bool where
104− encoding _ = Encoder.bool
105−instance HasEncoding ('Required ('NotNull 'PGBytea)) ByteString where
106− encoding _ = Encoder.bytea_strict
107−instance HasEncoding ('Required ('NotNull 'PGBytea)) Lazy.ByteString where
108− encoding _ = Encoder.bytea_lazy
109−instance HasEncoding ('Required ('NotNull 'PGText)) Text where
110− encoding _ = Encoder.text_strict
111−instance HasEncoding ('Required ('NotNull 'PGText)) Lazy.Text where
112− encoding _ = Encoder.text_lazy
113−instance HasEncoding ('Required ('NotNull ('PGChar 1))) Char where
114− encoding _ = Encoder.char_utf8
115−instance HasEncoding ('Required ('NotNull 'PGNumeric)) Scientific where
116− encoding _ = Encoder.numeric
117−instance HasEncoding ('Required ('NotNull 'PGUuid)) UUID where
118− encoding _ = Encoder.uuid
119−instance HasEncoding ('Required ('NotNull 'PGJson)) Aeson.Value where
120− encoding _ = Encoder.json_ast
121−instance HasEncoding ('Required ('NotNull 'PGJsonb)) Aeson.Value where
122− encoding _ = Encoder.jsonb_ast
123−instance HasEncoding ('Required ('NotNull 'PGDate)) Day where
124− encoding _ = Encoder.date
125−instance HasEncoding ('Required ('NotNull 'PGTime)) TimeOfDay where
126− encoding _ = Encoder.time_int
127−instance HasEncoding ('Required ('NotNull 'PGTimeTZ)) (TimeOfDay, TimeZone) where
128− encoding _ = Encoder.timetz_int
129−instance HasEncoding ('Required ('NotNull 'PGTimestamp)) LocalTime where
130− encoding _ = Encoder.timestamp_int
131−instance HasEncoding ('Required ('NotNull 'PGTimestampTZ)) UTCTime where
132− encoding _ = Encoder.timestamptz_int
133−instance HasEncoding ('Required ('NotNull 'PGInterval)) DiffTime where
134− encoding _ = Encoder.interval_int
135−
136−encodings
137− :: AllZip HasEncoding pgs xs
138− => proxy pgs
139− -> NP I xs
140− -> [ByteString]
141−encodings _ Nil = []
142−encodings (_ :: proxy pgs) (I x :* xs) =
143− case (hpure Proxy :: NP Proxy pgs) of
144− proxy :* proxies -> Encoder.encodingBytes (encoding proxy x)
145− : encodings proxies xs
squeel-postgresql/src/Squeel/PostgreSQL/Binary2.hs+47−47
@@ -35,36 +35,36 @@ import qualified PostgreSQL.Binary.Encoding as Encoding
3535import Squeel.PostgreSQL.Schema
3636
3737class ToParam x (pg :: PGType) where toParam :: x -> K Encoding.Encoding pg
38−instance ToParam Bool 'PGBool where toParam = K . Encoding.bool
39−instance ToParam Int16 'PGInt2 where toParam = K . Encoding.int2_int16
40−instance ToParam Word16 'PGInt2 where toParam = K . Encoding.int2_word16
41−instance ToParam Int32 'PGInt4 where toParam = K . Encoding.int4_int32
42−instance ToParam Word32 'PGInt4 where toParam = K . Encoding.int4_word32
43−instance ToParam Int64 'PGInt8 where toParam = K . Encoding.int8_int64
44−instance ToParam Word64 'PGInt8 where toParam = K . Encoding.int8_word64
45−instance ToParam Float 'PGFloat4 where toParam = K . Encoding.float4
46−instance ToParam Double 'PGFloat8 where toParam = K . Encoding.float8
47−instance ToParam Scientific 'PGNumeric where toParam = K . Encoding.numeric
48−instance ToParam UUID 'PGUuid where toParam = K . Encoding.uuid
49−instance ToParam (NetAddr IP) 'PGInet where toParam = K . Encoding.inet
50−instance ToParam Char ('PGChar 1) where toParam = K . Encoding.char_utf8
51−instance ToParam Strict.Text 'PGText where toParam = K . Encoding.text_strict
52−instance ToParam Lazy.Text 'PGText where toParam = K . Encoding.text_lazy
53−instance ToParam Strict.ByteString 'PGBytea where
38+instance ToParam Bool 'PGbool where toParam = K . Encoding.bool
39+instance ToParam Int16 'PGint2 where toParam = K . Encoding.int2_int16
40+instance ToParam Word16 'PGint2 where toParam = K . Encoding.int2_word16
41+instance ToParam Int32 'PGint4 where toParam = K . Encoding.int4_int32
42+instance ToParam Word32 'PGint4 where toParam = K . Encoding.int4_word32
43+instance ToParam Int64 'PGint8 where toParam = K . Encoding.int8_int64
44+instance ToParam Word64 'PGint8 where toParam = K . Encoding.int8_word64
45+instance ToParam Float 'PGfloat4 where toParam = K . Encoding.float4
46+instance ToParam Double 'PGfloat8 where toParam = K . Encoding.float8
47+instance ToParam Scientific 'PGnumeric where toParam = K . Encoding.numeric
48+instance ToParam UUID 'PGuuid where toParam = K . Encoding.uuid
49+instance ToParam (NetAddr IP) 'PGinet where toParam = K . Encoding.inet
50+instance ToParam Char ('PGchar 1) where toParam = K . Encoding.char_utf8
51+instance ToParam Strict.Text 'PGtext where toParam = K . Encoding.text_strict
52+instance ToParam Lazy.Text 'PGtext where toParam = K . Encoding.text_lazy
53+instance ToParam Strict.ByteString 'PGbytea where
5454 toParam = K . Encoding.bytea_strict
55−instance ToParam Lazy.ByteString 'PGBytea where
55+instance ToParam Lazy.ByteString 'PGbytea where
5656 toParam = K . Encoding.bytea_lazy
57−instance ToParam Day 'PGDate where toParam = K . Encoding.date
58−instance ToParam TimeOfDay 'PGTime where toParam = K . Encoding.time_int
59−instance ToParam (TimeOfDay, TimeZone) 'PGTimeTZ where
57+instance ToParam Day 'PGdate where toParam = K . Encoding.date
58+instance ToParam TimeOfDay 'PGtime where toParam = K . Encoding.time_int
59+instance ToParam (TimeOfDay, TimeZone) 'PGtimetz where
6060 toParam = K . Encoding.timetz_int
61−instance ToParam LocalTime 'PGTimestamp where
61+instance ToParam LocalTime 'PGtimestamp where
6262 toParam = K . Encoding.timestamp_int
63−instance ToParam UTCTime 'PGTimestampTZ where
63+instance ToParam UTCTime 'PGtimestamptz where
6464 toParam = K . Encoding.timestamptz_int
65−instance ToParam DiffTime 'PGInterval where toParam = K . Encoding.interval_int
66−instance ToParam Value 'PGJson where toParam = K . Encoding.json_ast
67−instance ToParam Value 'PGJsonb where toParam = K . Encoding.jsonb_ast
65+instance ToParam DiffTime 'PGinterval where toParam = K . Encoding.interval_int
66+instance ToParam Value 'PGjson where toParam = K . Encoding.json_ast
67+instance ToParam Value 'PGjsonb where toParam = K . Encoding.jsonb_ast
6868
6969class ToColumnParam x (ty :: ColumnType) where
7070 toColumnParam :: x -> K (Maybe Strict.ByteString) ty
@@ -87,37 +87,37 @@ instance (SListI tys, IsProductType x xs, AllZip ToColumnParam xs tys)
8787
8888class FromValue (pg :: PGType) y where
8989 fromValue :: proxy pg -> Decoding.Value y
90−instance FromValue 'PGBool Bool where fromValue _ = Decoding.bool
91−instance (Integral int, Bits int) => FromValue 'PGInt2 int where
90+instance FromValue 'PGbool Bool where fromValue _ = Decoding.bool
91+instance (Integral int, Bits int) => FromValue 'PGint2 int where
9292 fromValue _ = Decoding.int
93−instance (Integral int, Bits int) => FromValue 'PGInt4 int where
93+instance (Integral int, Bits int) => FromValue 'PGint4 int where
9494 fromValue _ = Decoding.int
95−instance (Integral int, Bits int) => FromValue 'PGInt8 int where
95+instance (Integral int, Bits int) => FromValue 'PGint8 int where
9696 fromValue _ = Decoding.int
97−instance FromValue 'PGFloat4 Float where fromValue _ = Decoding.float4
98−instance FromValue 'PGFloat8 Double where fromValue _ = Decoding.float8
99−instance FromValue 'PGNumeric Scientific where fromValue _ = Decoding.numeric
100−instance FromValue 'PGUuid UUID where fromValue _ = Decoding.uuid
101−instance FromValue 'PGInet (NetAddr IP) where fromValue _ = Decoding.inet
102−instance FromValue ('PGChar 1) Char where fromValue _ = Decoding.char
103−instance FromValue 'PGText Strict.Text where fromValue _ = Decoding.text_strict
104−instance FromValue 'PGText Lazy.Text where fromValue _ = Decoding.text_lazy
105−instance FromValue 'PGBytea Strict.ByteString where
97+instance FromValue 'PGfloat4 Float where fromValue _ = Decoding.float4
98+instance FromValue 'PGfloat8 Double where fromValue _ = Decoding.float8
99+instance FromValue 'PGnumeric Scientific where fromValue _ = Decoding.numeric
100+instance FromValue 'PGuuid UUID where fromValue _ = Decoding.uuid
101+instance FromValue 'PGinet (NetAddr IP) where fromValue _ = Decoding.inet
102+instance FromValue ('PGchar 1) Char where fromValue _ = Decoding.char
103+instance FromValue 'PGtext Strict.Text where fromValue _ = Decoding.text_strict
104+instance FromValue 'PGtext Lazy.Text where fromValue _ = Decoding.text_lazy
105+instance FromValue 'PGbytea Strict.ByteString where
106106 fromValue _ = Decoding.bytea_strict
107−instance FromValue 'PGBytea Lazy.ByteString where
107+instance FromValue 'PGbytea Lazy.ByteString where
108108 fromValue _ = Decoding.bytea_lazy
109−instance FromValue 'PGDate Day where fromValue _ = Decoding.date
110−instance FromValue 'PGTime TimeOfDay where fromValue _ = Decoding.time_int
111−instance FromValue 'PGTimeTZ (TimeOfDay, TimeZone) where
109+instance FromValue 'PGdate Day where fromValue _ = Decoding.date
110+instance FromValue 'PGtime TimeOfDay where fromValue _ = Decoding.time_int
111+instance FromValue 'PGtimetz (TimeOfDay, TimeZone) where
112112 fromValue _ = Decoding.timetz_int
113−instance FromValue 'PGTimestamp LocalTime where
113+instance FromValue 'PGtimestamp LocalTime where
114114 fromValue _ = Decoding.timestamp_int
115−instance FromValue 'PGTimestampTZ UTCTime where
115+instance FromValue 'PGtimestamptz UTCTime where
116116 fromValue _ = Decoding.timestamptz_int
117−instance FromValue 'PGInterval DiffTime where
117+instance FromValue 'PGinterval DiffTime where
118118 fromValue _ = Decoding.interval_int
119−instance FromValue 'PGJson Value where fromValue _ = Decoding.json_ast
120−instance FromValue 'PGJsonb Value where fromValue _ = Decoding.jsonb_ast
119+instance FromValue 'PGjson Value where fromValue _ = Decoding.json_ast
120+instance FromValue 'PGjsonb Value where fromValue _ = Decoding.jsonb_ast
121121
122122class FromColumnValue (colty :: (Symbol,ColumnType)) y where
123123 fromColumnValue :: K (Maybe Strict.ByteString) colty -> y
squeel-postgresql/src/Squeel/PostgreSQL/Schema.hs+38−56
@@ -15,10 +15,8 @@
1515
1616module Squeel.PostgreSQL.Schema
1717 ( PGType (..)
18− , ToOid (..)
19− , ToOids (..)
2018 , PGNum (..)
21− , PGFractional
19+ , PGIntegral
2220 , PGFloating
2321 , (:::)
2422 , Alias (Alias)
@@ -49,63 +47,47 @@ import GHC.Exts
4947import GHC.OverloadedLabels
5048import GHC.TypeLits
5149
52−import qualified Database.PostgreSQL.LibPQ as LibPQ
53−
5450data PGType
55− = PGBool
56− | PGInt2
57− | PGInt4
58− | PGInt8
59− | PGNumeric
60− | PGFloat4
61− | PGFloat8
62− | PGMoney
63− | PGChar Nat
64− | PGVarChar Nat
65− | PGText
66− | PGBytea
67− | PGTimestamp
68− | PGTimestampTZ
69− | PGDate
70− | PGTime
71− | PGTimeTZ
72− | PGInterval
73− | PGUuid
74− | PGInet
75− | PGJson
76− | PGJsonb
77−
78−class ToOid pg where toOid :: Proxy# pg -> LibPQ.Oid
79−--staticTypeInfo
80−instance ToOid ('Required ('NotNull 'PGBool)) where toOid _ = LibPQ.Oid 16
81−instance ToOid ('Required ('NotNull 'PGBytea)) where toOid _ = LibPQ.Oid 17
82−instance ToOid ('Required ('NotNull 'PGInt8)) where toOid _ = LibPQ.Oid 20
83−instance ToOid ('Required ('NotNull 'PGInt2)) where toOid _ = LibPQ.Oid 21
84−instance ToOid ('Required ('NotNull 'PGInt4)) where toOid _ = LibPQ.Oid 23
85−instance ToOid ('Required ('NotNull 'PGText)) where toOid _ = LibPQ.Oid 26
86−class ToOids pgs where toOids :: Proxy# pgs -> [LibPQ.Oid]
87−instance ToOids '[] where toOids _ = []
88−instance (ToOid pg, ToOids pgs) => ToOids (pg ': pgs) where
89− toOids _ = toOid (proxy# :: Proxy# pg) : toOids (proxy# :: Proxy# pgs)
51+ = PGbool
52+ | PGint2
53+ | PGint4
54+ | PGint8
55+ | PGnumeric
56+ | PGfloat4
57+ | PGfloat8
58+ | PGchar Nat
59+ | PGvarchar Nat
60+ | PGtext
61+ | PGbytea
62+ | PGtimestamp
63+ | PGtimestamptz
64+ | PGdate
65+ | PGtime
66+ | PGtimetz
67+ | PGinterval
68+ | PGuuid
69+ | PGinet
70+ | PGjson
71+ | PGjsonb
9072
9173class PGNum (ty :: PGType) where
9274 decimal :: proxy ty -> Bool
93−instance PGNum 'PGInt2 where decimal _ = False
94−instance PGNum 'PGInt4 where decimal _ = False
95−instance PGNum 'PGInt8 where decimal _ = False
96−instance PGNum 'PGNumeric where decimal _ = True
97−instance PGNum 'PGFloat4 where decimal _ = True
98−instance PGNum 'PGFloat8 where decimal _ = True
99−
100−class PGNum ty => PGFractional (ty :: PGType) where
101−instance PGFractional 'PGNumeric
102−instance PGFractional 'PGFloat4
103−instance PGFractional 'PGFloat8
104−
105−class PGFractional ty => PGFloating (ty :: PGType) where
106−instance PGFloating 'PGNumeric
107−instance PGFloating 'PGFloat4
108−instance PGFloating 'PGFloat8
75+instance PGNum 'PGint2 where decimal _ = False
76+instance PGNum 'PGint4 where decimal _ = False
77+instance PGNum 'PGint8 where decimal _ = False
78+instance PGNum 'PGnumeric where decimal _ = True
79+instance PGNum 'PGfloat4 where decimal _ = True
80+instance PGNum 'PGfloat8 where decimal _ = True
81+
82+class PGNum ty => PGIntegral (ty :: PGType) where
83+instance PGIntegral 'PGint2
84+instance PGIntegral 'PGint4
85+instance PGIntegral 'PGint8
86+
87+class PGNum ty => PGFloating (ty :: PGType) where
88+instance PGFloating 'PGnumeric
89+instance PGFloating 'PGfloat4
90+instance PGFloating 'PGfloat8
10991
11092type (:::) (alias :: Symbol) (ty :: polykind) = '(alias,ty)
11193
squeel-postgresql/src/Squeel/PostgreSQL/Statement.hs+87−101
@@ -140,12 +140,12 @@ instance PGNum ty
140140 . fromString
141141 . show
142142
143−instance PGFractional ty => Fractional
143+instance PGFloating ty => Fractional
144144 (Expression params tables grouping ('Required (nullity ty))) where
145145 (/) = unsafeBinaryOp "/"
146146 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
147147
148−instance (PGFloating ty, PGCast 'PGNumeric ty, PGTyped ty) => Floating
148+instance (PGFloating ty, PGTyped ty) => Floating
149149 (Expression params tables grouping ('Required (nullity ty))) where
150150 pi = UnsafeExpression "pi()"
151151 exp = unsafeFunction "exp"
@@ -158,12 +158,12 @@ instance (PGFloating ty, PGCast 'PGNumeric ty, PGTyped ty) => Floating
158158 logBaseNumeric
159159 :: Expression params tables grouping ('Required (nullity ty))
160160 -> Expression params tables grouping ('Required (nullity ty))
161− -> Expression params tables grouping ('Required (nullity 'PGNumeric))
161+ -> Expression params tables grouping ('Required (nullity 'PGnumeric))
162162 logBaseNumeric b' y' = UnsafeExpression $ mconcat
163163 [ "log("
164− , renderExpression b' <> "::numeric"
164+ , renderExpression (cast numeric b')
165165 , ", "
166− , renderExpression y' <> "::numeric"
166+ , renderExpression (cast numeric y')
167167 , ")"
168168 ]
169169 sin = unsafeFunction "sin"
@@ -187,75 +187,62 @@ atan2
187187atan2 y x = UnsafeExpression $
188188 "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
189189
190−class PGCast (ty0 :: PGType) (ty1 :: PGType) where
191− cast
192− :: TypeExpression ('Required ('Null ty1))
193− -> Expression params tables grouping ('Required (nullity ty0))
194− -> Expression params tables grouping ('Required (nullity ty1))
195− cast ty x = UnsafeExpression $
196− "(" <> renderExpression x <> "::" <> renderTypeExpression ty <> ")"
197−instance PGCast 'PGInt2 'PGInt2
198−instance PGCast 'PGInt2 'PGInt4
199−instance PGCast 'PGInt2 'PGInt8
200−instance PGCast 'PGInt4 'PGInt2
201−instance PGCast 'PGInt4 'PGInt4
202−instance PGCast 'PGInt4 'PGInt8
203−instance PGCast 'PGInt8 'PGInt2
204−instance PGCast 'PGInt8 'PGInt4
205−instance PGCast 'PGInt8 'PGInt8
206−instance PGCast 'PGInt8 'PGFloat4
207−instance PGCast 'PGInt8 'PGFloat8
208−instance PGCast 'PGInt8 'PGNumeric
190+cast
191+ :: TypeExpression ('Required ('Null ty1))
192+ -> Expression params tables grouping ('Required (nullity ty0))
193+ -> Expression params tables grouping ('Required (nullity ty1))
194+cast ty x = UnsafeExpression $
195+ "(" <> renderExpression x <> " :: " <> renderTypeExpression ty <> ")"
209196
210197div
211− :: (PGNum ty, PGTyped ty, PGCast 'PGInt8 ty, PGCast ty 'PGInt8)
198+ :: PGIntegral ty
212199 => Expression params tables grouping ('Required (nullity ty))
213200 -> Expression params tables grouping ('Required (nullity ty))
214201 -> Expression params tables grouping ('Required (nullity ty))
215202div = unsafeBinaryOp "/"
216203
217204mod
218− :: (PGNum ty, PGTyped ty, PGCast 'PGInt8 ty, PGCast ty 'PGInt8)
205+ :: PGIntegral ty
219206 => Expression params tables grouping ('Required (nullity ty))
220207 -> Expression params tables grouping ('Required (nullity ty))
221208 -> Expression params tables grouping ('Required (nullity ty))
222209mod = unsafeBinaryOp "%"
223210
224211truncate
225− :: (PGFractional frac, PGCast 'PGInt4 int, PGTyped int)
212+ :: (PGFloating frac, PGTyped int)
226213 => Expression params tables grouping ('Required (nullity frac))
227214 -> Expression params tables grouping ('Required (nullity int))
228215truncate = cast pgtype . truncate'
229216 where
230217 truncate'
231218 :: Expression params tables grouping ('Required (nullity frac))
232− -> Expression params tables grouping ('Required (nullity 'PGInt4))
219+ -> Expression params tables grouping ('Required (nullity frac))
233220 truncate' = unsafeFunction "trunc"
234221
235222round
236− :: (PGFractional frac, PGCast 'PGInt4 int, PGTyped int)
223+ :: (PGFloating frac, PGTyped int)
237224 => Expression params tables grouping ('Required (nullity frac))
238225 -> Expression params tables grouping ('Required (nullity int))
239226round = cast pgtype . round'
240227 where
241228 round'
242229 :: Expression params tables grouping ('Required (nullity frac))
243− -> Expression params tables grouping ('Required (nullity 'PGInt4))
230+ -> Expression params tables grouping ('Required (nullity frac))
244231 round' = unsafeFunction "round"
245232
246233ceiling
247− :: (PGFractional frac, PGCast 'PGInt4 int, PGTyped int)
234+ :: (PGFloating frac, PGTyped int)
248235 => Expression params tables grouping ('Required (nullity frac))
249236 -> Expression params tables grouping ('Required (nullity int))
250237ceiling = cast pgtype . ceiling'
251238 where
252239 ceiling'
253240 :: Expression params tables grouping ('Required (nullity frac))
254− -> Expression params tables grouping ('Required (nullity 'PGInt4))
241+ -> Expression params tables grouping ('Required (nullity frac))
255242 ceiling' = unsafeFunction "ceiling"
256243
257244instance IsString
258− (Expression params tables grouping ('Required (nullity 'PGText))) where
245+ (Expression params tables grouping ('Required (nullity 'PGtext))) where
259246 fromString str = UnsafeExpression $
260247 "E\'" <> fromString (escape =<< str) <> "\'"
261248 where
@@ -271,7 +258,7 @@ instance IsString
271258 c -> [c]
272259
273260type Condition params tables grouping =
274− Expression params tables grouping ('Required ('NotNull 'PGBool))
261+ Expression params tables grouping ('Required ('NotNull 'PGbool))
275262
276263true :: Condition params tables grouping
277264true = UnsafeExpression "TRUE"
@@ -323,37 +310,37 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
323310(==*)
324311 :: Expression params tables grouping ('Required (nullity ty))
325312 -> Expression params tables grouping ('Required (nullity ty))
326− -> Expression params tables grouping ('Required (nullity 'PGBool))
313+ -> Expression params tables grouping ('Required (nullity 'PGbool))
327314(==*) = unsafeBinaryOp "="
328315
329316(/=*)
330317 :: Expression params tables grouping ('Required (nullity ty))
331318 -> Expression params tables grouping ('Required (nullity ty))
332− -> Expression params tables grouping ('Required (nullity 'PGBool))
319+ -> Expression params tables grouping ('Required (nullity 'PGbool))
333320(/=*) = unsafeBinaryOp "<>"
334321
335322(>=*)
336323 :: Expression params tables grouping ('Required (nullity ty))
337324 -> Expression params tables grouping ('Required (nullity ty))
338− -> Expression params tables grouping ('Required (nullity 'PGBool))
325+ -> Expression params tables grouping ('Required (nullity 'PGbool))
339326(>=*) = unsafeBinaryOp ">="
340327
341328(<*)
342329 :: Expression params tables grouping ('Required (nullity ty))
343330 -> Expression params tables grouping ('Required (nullity ty))
344− -> Expression params tables grouping ('Required (nullity 'PGBool))
331+ -> Expression params tables grouping ('Required (nullity 'PGbool))
345332(<*) = unsafeBinaryOp "<"
346333
347334(<=*)
348335 :: Expression params tables grouping ('Required (nullity ty))
349336 -> Expression params tables grouping ('Required (nullity ty))
350− -> Expression params tables grouping ('Required (nullity 'PGBool))
337+ -> Expression params tables grouping ('Required (nullity 'PGbool))
351338(<=*) = unsafeBinaryOp "<="
352339
353340(>*)
354341 :: Expression params tables grouping ('Required (nullity ty))
355342 -> Expression params tables grouping ('Required (nullity ty))
356− -> Expression params tables grouping ('Required (nullity 'PGBool))
343+ -> Expression params tables grouping ('Required (nullity 'PGbool))
357344(>*) = unsafeBinaryOp ">"
358345
359346data SortExpression params tables grouping where
@@ -640,91 +627,89 @@ newtype TypeExpression (ty :: ColumnType)
640627 = UnsafeTypeExpression { renderTypeExpression :: ByteString }
641628 deriving (Show,Eq)
642629
643−bool :: TypeExpression ('Required ('Null 'PGBool))
630+bool :: TypeExpression ('Required ('Null 'PGbool))
644631bool = UnsafeTypeExpression "bool"
645−int2 :: TypeExpression ('Required ('Null 'PGInt2))
632+int2 :: TypeExpression ('Required ('Null 'PGint2))
646633int2 = UnsafeTypeExpression "int2"
647−smallint :: TypeExpression ('Required ('Null 'PGInt2))
634+smallint :: TypeExpression ('Required ('Null 'PGint2))
648635smallint = UnsafeTypeExpression "smallint"
649−int4 :: TypeExpression ('Required ('Null 'PGInt4))
636+int4 :: TypeExpression ('Required ('Null 'PGint4))
650637int4 = UnsafeTypeExpression "int4"
651−int :: TypeExpression ('Required ('Null 'PGInt4))
638+int :: TypeExpression ('Required ('Null 'PGint4))
652639int = UnsafeTypeExpression "int"
653−integer :: TypeExpression ('Required ('Null 'PGInt4))
640+integer :: TypeExpression ('Required ('Null 'PGint4))
654641integer = UnsafeTypeExpression "integer"
655−int8 :: TypeExpression ('Required ('Null 'PGInt8))
642+int8 :: TypeExpression ('Required ('Null 'PGint8))
656643int8 = UnsafeTypeExpression "int8"
657−bigint :: TypeExpression ('Required ('Null 'PGInt8))
644+bigint :: TypeExpression ('Required ('Null 'PGint8))
658645bigint = UnsafeTypeExpression "bigint"
659−numeric :: TypeExpression ('Required ('Null 'PGNumeric))
646+numeric :: TypeExpression ('Required ('Null 'PGnumeric))
660647numeric = UnsafeTypeExpression "numeric"
661−float4 :: TypeExpression ('Required ('Null 'PGFloat4))
648+float4 :: TypeExpression ('Required ('Null 'PGfloat4))
662649float4 = UnsafeTypeExpression "float4"
663−real :: TypeExpression ('Required ('Null 'PGFloat4))
650+real :: TypeExpression ('Required ('Null 'PGfloat4))
664651real = UnsafeTypeExpression "real"
665−float8 :: TypeExpression ('Required ('Null 'PGFloat8))
652+float8 :: TypeExpression ('Required ('Null 'PGfloat8))
666653float8 = UnsafeTypeExpression "float8"
667−doublePrecision :: TypeExpression ('Required ('Null 'PGFloat8))
654+doublePrecision :: TypeExpression ('Required ('Null 'PGfloat8))
668655doublePrecision = UnsafeTypeExpression "double precision"
669−serial2 :: TypeExpression ('Optional ('NotNull 'PGInt2))
656+serial2 :: TypeExpression ('Optional ('NotNull 'PGint2))
670657serial2 = UnsafeTypeExpression "serial2"
671−smallserial :: TypeExpression ('Optional ('NotNull 'PGInt2))
658+smallserial :: TypeExpression ('Optional ('NotNull 'PGint2))
672659smallserial = UnsafeTypeExpression "smallserial"
673−serial4 :: TypeExpression ('Optional ('NotNull 'PGInt4))
660+serial4 :: TypeExpression ('Optional ('NotNull 'PGint4))
674661serial4 = UnsafeTypeExpression "serial4"
675−serial :: TypeExpression ('Optional ('NotNull 'PGInt4))
662+serial :: TypeExpression ('Optional ('NotNull 'PGint4))
676663serial = UnsafeTypeExpression "serial"
677−serial8 :: TypeExpression ('Optional ('NotNull 'PGInt8))
664+serial8 :: TypeExpression ('Optional ('NotNull 'PGint8))
678665serial8 = UnsafeTypeExpression "serial8"
679−bigserial :: TypeExpression ('Optional ('NotNull 'PGInt8))
666+bigserial :: TypeExpression ('Optional ('NotNull 'PGint8))
680667bigserial = UnsafeTypeExpression "bigserial"
681−money :: TypeExpression ('Required ('Null 'PGMoney))
682−money = UnsafeTypeExpression "money"
683−text :: TypeExpression ('Required ('Null 'PGText))
668+text :: TypeExpression ('Required ('Null 'PGtext))
684669text = UnsafeTypeExpression "text"
685670char
686671 :: KnownNat n
687672 => proxy n
688− -> TypeExpression ('Required ('Null ('PGChar n)))
673+ -> TypeExpression ('Required ('Null ('PGchar n)))
689674char (_ :: proxy n) = UnsafeTypeExpression $
690675 "char(" <> fromString (show (natVal' (proxy# :: Proxy# n))) <> ")"
691676character
692677 :: KnownNat n
693678 => proxy n
694− -> TypeExpression ('Required ('Null ('PGChar n)))
679+ -> TypeExpression ('Required ('Null ('PGchar n)))
695680character (_ :: proxy n) = UnsafeTypeExpression $
696681 "character(" <> fromString (show (natVal' (proxy# :: Proxy# n))) <> ")"
697682varchar
698683 :: KnownNat n
699684 => proxy n
700− -> TypeExpression ('Required ('Null ('PGVarChar n)))
685+ -> TypeExpression ('Required ('Null ('PGvarchar n)))
701686varchar (_ :: proxy n) = UnsafeTypeExpression $
702687 "varchar(" <> fromString (show (natVal' (proxy# :: Proxy# n))) <> ")"
703688characterVarying
704689 :: KnownNat n
705690 => proxy n
706− -> TypeExpression ('Required ('Null ('PGVarChar n)))
707−characterVarying (_ :: proxy n) = UnsafeTypeExpression $
708− "character varying(" <> fromString (show (natVal' (proxy# :: Proxy# n))) <> ")"
709−bytea :: TypeExpression ('Required ('Null ('PGBytea)))
691+ -> TypeExpression ('Required ('Null ('PGvarchar n)))
692+characterVarying p = UnsafeTypeExpression $
693+ "character varying(" <> renderNat p <> ")"
694+bytea :: TypeExpression ('Required ('Null ('PGbytea)))
710695bytea = UnsafeTypeExpression "bytea"
711−timestamp :: TypeExpression ('Required ('Null ('PGTimestamp)))
696+timestamp :: TypeExpression ('Required ('Null ('PGtimestamp)))
712697timestamp = UnsafeTypeExpression "timestamp"
713−timestampWithTimeZone :: TypeExpression ('Required ('Null ('PGTimestampTZ)))
698+timestampWithTimeZone :: TypeExpression ('Required ('Null ('PGtimestamptz)))
714699timestampWithTimeZone = UnsafeTypeExpression "timestamp with time zone"
715−date :: TypeExpression ('Required ('Null ('PGDate)))
700+date :: TypeExpression ('Required ('Null ('PGdate)))
716701date = UnsafeTypeExpression "date"
717−time :: TypeExpression ('Required ('Null ('PGTime)))
702+time :: TypeExpression ('Required ('Null ('PGtime)))
718703time = UnsafeTypeExpression "time"
719−timeWithTimeZone :: TypeExpression ('Required ('Null ('PGTimeTZ)))
704+timeWithTimeZone :: TypeExpression ('Required ('Null ('PGtimetz)))
720705timeWithTimeZone = UnsafeTypeExpression "time with time zone"
721−interval :: TypeExpression ('Required ('Null ('PGInterval)))
706+interval :: TypeExpression ('Required ('Null ('PGinterval)))
722707interval = UnsafeTypeExpression "interval"
723−uuid :: TypeExpression ('Required ('Null ('PGUuid)))
708+uuid :: TypeExpression ('Required ('Null ('PGuuid)))
724709uuid = UnsafeTypeExpression "uuid"
725−json :: TypeExpression ('Required ('Null ('PGJson)))
710+json :: TypeExpression ('Required ('Null ('PGjson)))
726711json = UnsafeTypeExpression "json"
727−jsonb :: TypeExpression ('Required ('Null ('PGJsonb)))
712+jsonb :: TypeExpression ('Required ('Null ('PGjsonb)))
728713jsonb = UnsafeTypeExpression "jsonb"
729714
730715notNull
@@ -740,27 +725,26 @@ default_ x ty = UnsafeTypeExpression $
740725
741726class PGTyped (ty :: PGType) where
742727 pgtype :: TypeExpression ('Required ('Null ty))
743−instance PGTyped 'PGBool where pgtype = bool
744−instance PGTyped 'PGInt2 where pgtype = int2
745−instance PGTyped 'PGInt4 where pgtype = int4
746−instance PGTyped 'PGInt8 where pgtype = int8
747−instance PGTyped 'PGNumeric where pgtype = numeric
748−instance PGTyped 'PGFloat4 where pgtype = float4
749−instance PGTyped 'PGFloat8 where pgtype = float8
750−instance PGTyped 'PGMoney where pgtype = money
751−instance PGTyped 'PGText where pgtype = text
752−instance KnownNat n => PGTyped ('PGChar n) where pgtype = char (Proxy @n)
753−instance KnownNat n => PGTyped ('PGVarChar n) where pgtype = varchar (Proxy @n)
754−instance PGTyped 'PGBytea where pgtype = bytea
755−instance PGTyped 'PGTimestamp where pgtype = timestamp
756−instance PGTyped 'PGTimestampTZ where pgtype = timestampWithTimeZone
757−instance PGTyped 'PGDate where pgtype = date
758−instance PGTyped 'PGTime where pgtype = time
759−instance PGTyped 'PGTimeTZ where pgtype = timeWithTimeZone
760−instance PGTyped 'PGInterval where pgtype = interval
761−instance PGTyped 'PGUuid where pgtype = uuid
762−instance PGTyped 'PGJson where pgtype = json
763−instance PGTyped 'PGJsonb where pgtype = jsonb
728+instance PGTyped 'PGbool where pgtype = bool
729+instance PGTyped 'PGint2 where pgtype = int2
730+instance PGTyped 'PGint4 where pgtype = int4
731+instance PGTyped 'PGint8 where pgtype = int8
732+instance PGTyped 'PGnumeric where pgtype = numeric
733+instance PGTyped 'PGfloat4 where pgtype = float4
734+instance PGTyped 'PGfloat8 where pgtype = float8
735+instance PGTyped 'PGtext where pgtype = text
736+instance KnownNat n => PGTyped ('PGchar n) where pgtype = char (Proxy @n)
737+instance KnownNat n => PGTyped ('PGvarchar n) where pgtype = varchar (Proxy @n)
738+instance PGTyped 'PGbytea where pgtype = bytea
739+instance PGTyped 'PGtimestamp where pgtype = timestamp
740+instance PGTyped 'PGtimestamptz where pgtype = timestampWithTimeZone
741+instance PGTyped 'PGdate where pgtype = date
742+instance PGTyped 'PGtime where pgtype = time
743+instance PGTyped 'PGtimetz where pgtype = timeWithTimeZone
744+instance PGTyped 'PGinterval where pgtype = interval
745+instance PGTyped 'PGuuid where pgtype = uuid
746+instance PGTyped 'PGjson where pgtype = json
747+instance PGTyped 'PGjsonb where pgtype = jsonb
764748
765749{-----------------------------------------
766750statements
@@ -1043,8 +1027,7 @@ dropNotNull
10431027dropNotNull = UnsafeAlterColumn $ "DROP NOT NULL"
10441028
10451029alterType
1046− :: PGCast ty0 ty1
1047− => TypeExpression (optionality (nullity ty1))
1030+ :: TypeExpression (optionality (nullity ty1))
10481031 -> AlterColumn (optionality (nullity ty0)) (optionality (nullity ty1))
10491032alterType ty = UnsafeAlterColumn $ "TYPE " <> renderTypeExpression ty
10501033
@@ -1210,3 +1193,6 @@ renderCommaSeparatedMaybe render
12101193
12111194renderSymbol :: KnownSymbol str => Proxy# str -> ByteString
12121195renderSymbol p = fromString $ symbolVal' p
1196+
1197+renderNat :: KnownNat n => proxy n -> ByteString
1198+renderNat (_ :: proxy n) = fromString (show (natVal' (proxy# :: Proxy# n)))
squeel-postgresql/test/Squeel/PostgreSQL/StatementSpec.hs+29−24
@@ -3,6 +3,7 @@
33 , MagicHash
44 , OverloadedLabels
55 , OverloadedStrings
6+ , TypeApplications
67 , TypeOperators
78#-}
89
@@ -66,10 +67,11 @@ spec = do
6667 statement `queryRenders` "SELECT * FROM table1 AS table1 LIMIT 1;"
6768 it "should render parameters using $ signs" $ do
6869 let
69− statement :: Query Tables '[ 'Required ('NotNull 'PGBool)] Columns
70− statement =
71− selectStar (from (Table (#table1 `As` #table1)) & where_ param1)
72− statement `queryRenders` "SELECT * FROM table1 AS table1 WHERE $1;"
70+ statement :: Query Tables '[ 'Required ('NotNull 'PGbool)] Columns
71+ statement = selectStar
72+ (from (Table (#table1 `As` #table1)) & where_ (param (Proxy @1)))
73+ statement `queryRenders`
74+ "SELECT * FROM table1 AS table1 WHERE ($1 :: bool);"
7375 it "does OFFSET clauses" $ do
7476 let
7577 statement :: Query Tables '[] Columns
@@ -247,13 +249,13 @@ spec = do
247249 let
248250 statement :: Definition '[]
249251 '[ "users" :::
250− '[ "id" ::: 'Optional ('NotNull 'PGInt4)
251− , "username" ::: 'Required ('NotNull 'PGText)
252+ '[ "id" ::: 'Optional ('NotNull 'PGint4)
253+ , "username" ::: 'Required ('NotNull 'PGtext)
252254 ]
253255 , "emails" :::
254− '[ "id" ::: 'Optional ('NotNull 'PGInt4)
255− , "userid" ::: 'Required ('NotNull 'PGInt4)
256− , "email" ::: 'Required ('NotNull 'PGText)
256+ '[ "id" ::: 'Optional ('NotNull 'PGint4)
257+ , "userid" ::: 'Required ('NotNull 'PGint4)
258+ , "email" ::: 'Required ('NotNull 'PGtext)
257259 ]
258260 ]
259261 statement =
@@ -290,26 +292,29 @@ spec = do
290292 statement `definitionRenders` "DROP TABLE table1;"
291293
292294type Columns =
293− '[ "col1" ::: 'Required ('NotNull 'PGInt4)
294− , "col2" ::: 'Required ('NotNull 'PGInt4)
295+ '[ "col1" ::: 'Required ('NotNull 'PGint4)
296+ , "col2" ::: 'Required ('NotNull 'PGint4)
295297 ]
296298type Tables = '[ "table1" ::: Columns ]
297−type SumAndCol1 = '[ "sum" ::: 'Required ('NotNull 'PGInt4), "col1" ::: 'Required ('NotNull 'PGInt4)]
298−type StudentsColumns = '["name" ::: 'Required ('NotNull 'PGText)]
299+type SumAndCol1 =
300+ '[ "sum" ::: 'Required ('NotNull 'PGint4)
301+ , "col1" ::: 'Required ('NotNull 'PGint4)
302+ ]
303+type StudentsColumns = '["name" ::: 'Required ('NotNull 'PGtext)]
299304type StudentsTable = '["students" ::: StudentsColumns]
300305type OrderColumns =
301− '[ "orderID" ::: 'Required ('NotNull 'PGInt4)
302− , "orderVal" ::: 'Required ('NotNull 'PGText)
303− , "customerID" ::: 'Required ('NotNull 'PGInt4)
304− , "shipperID" ::: 'Required ('NotNull 'PGInt4)
306+ '[ "orderID" ::: 'Required ('NotNull 'PGint4)
307+ , "orderVal" ::: 'Required ('NotNull 'PGtext)
308+ , "customerID" ::: 'Required ('NotNull 'PGint4)
309+ , "shipperID" ::: 'Required ('NotNull 'PGint4)
305310 ]
306311type CustomerColumns =
307− '[ "customerID" ::: 'Required ('NotNull 'PGInt4)
308− , "customerVal" ::: 'Required ('NotNull 'PGFloat4)
312+ '[ "customerID" ::: 'Required ('NotNull 'PGint4)
313+ , "customerVal" ::: 'Required ('NotNull 'PGfloat4)
309314 ]
310315type ShipperColumns =
311− '[ "shipperID" ::: 'Required ('NotNull 'PGInt4)
312− , "shipperVal" ::: 'Required ('NotNull 'PGBool)
316+ '[ "shipperID" ::: 'Required ('NotNull 'PGint4)
317+ , "shipperVal" ::: 'Required ('NotNull 'PGbool)
313318 ]
314319type JoinTables =
315320 '[ "orders" ::: OrderColumns
@@ -317,7 +322,7 @@ type JoinTables =
317322 , "shippers" ::: ShipperColumns
318323 ]
319324type ValueColumns =
320− '[ "orderVal" ::: 'Required ('NotNull 'PGText)
321− , "customerVal" ::: 'Required ('NotNull 'PGFloat4)
322− , "shipperVal" ::: 'Required ('NotNull 'PGBool)
325+ '[ "orderVal" ::: 'Required ('NotNull 'PGtext)
326+ , "customerVal" ::: 'Required ('NotNull 'PGfloat4)
327+ , "shipperVal" ::: 'Required ('NotNull 'PGbool)
323328 ]