@@ -8,6 +8,8 @@ import Test.QuickCheck.Monadic
8
8
9
9
import Data.Scientific as S
10
10
import Data.Time
11
+ import Text.Printf
12
+ import Data.List as L
11
13
import Data.UUID (UUID , fromWords )
12
14
import Data.String (IsString )
13
15
import qualified Data.ByteString as B
@@ -118,20 +120,30 @@ testCodecsEncodeDecode = testGroup "Codecs property 'encode . decode = id'"
118
120
testCodecsEncodePrint :: TestTree
119
121
testCodecsEncodePrint = testGroup
120
122
" Codecs property 'Encoded value Postgres = value in Haskell'"
121
- [ mkCodecEncodeTest " uuid " PGT. uuid qBasic PE. uuid show
123
+ [ mkCodecEncodeTest " bool " PGT. bool qBasic PE. bool displayBool
122
124
, mkCodecEncodeTest " date" PGT. date qBasic PE. date show
123
- , mkCodecEncodeTest " timestamp" PGT. timestamp qBasic PE. timestamp show
124
- , mkCodecEncodeTest " timestamptz" PGT. timestamptz
125
- " SELECT ($1 at time zone 'UTC')||' UTC'" PE. timestamptz show
125
+ , mkCodecEncodeTest " float8" PGT. float8
126
+ " SELECT trim(to_char($1, '99999999999990.9999999999'))"
127
+ PE. float8 (printf " %.10f" )
128
+ , mkCodecEncodeTest " int8" PGT. int8 qBasic PE. int8 show
126
129
, mkCodecEncodeTest " interval" PGT. interval
127
130
" SELECT extract(epoch from $1)||'s'" PE. interval show
128
131
, mkCodecEncodeTest " numeric" PGT. numeric qBasic PE. numeric
129
132
displayScientific
133
+ , mkCodecEncodeTest " timestamp" PGT. timestamp qBasic PE. timestamp show
134
+ , mkCodecEncodeTest " timestamptz" PGT. timestamptz
135
+ " SELECT ($1 at time zone 'UTC')||' UTC'" PE. timestamptz show
136
+ , mkCodecEncodeTest " uuid" PGT. uuid qBasic PE. uuid show
130
137
]
131
138
where
132
139
qBasic = " SELECT $1"
140
+
133
141
displayScientific s | isInteger s = show $ ceiling s
134
142
| otherwise = formatScientific S. Fixed Nothing s
143
+
144
+ displayBool False = " f"
145
+ displayBool True = " t"
146
+
135
147
--
136
148
-- Orphan instances
137
149
--
0 commit comments