@@ -166,28 +166,35 @@ marshalTest' cmp gen postgresConn =
166
166
assertBool " Hedgehog test failed" passes
167
167
168
168
169
- -- Ensure that `Maybe (Vector Text)` can be marshalled correctly (See issue 692).
169
+ -- Ensure that both `Vector Text` and `Maybe (Vector Text)` can be
170
+ -- marshalled correctly (see issue 692).
170
171
--
171
172
-- At this time, the postgres migration backend can't create columns of arrays,
172
173
-- and hence this test does not use `marshalTest`.
173
174
marshalTest692 :: IO ByteString -> TestTree
174
175
marshalTest692 postgresConn =
175
- testCase " Can marshal Maybe (Vector Text) (#692)" $
176
+ testCase " Can marshal Vector Text and Maybe (Vector Text) (#692)" $
176
177
withTestPostgres (" db_marshal_maybe_vector_text_issue_692" ) postgresConn $ \ conn -> do
177
- liftIO $ execute_ conn $ " CREATE TABLE mytable (\n myid SERIAL PRIMARY KEY, mycolumn text[]\n );"
178
+ liftIO $ execute_ conn $ " CREATE TABLE mytable (\n myid SERIAL PRIMARY KEY, mycolumn text[], mynullablecolumn text[] \n );"
178
179
179
180
passes <- Hedgehog. check . Hedgehog. property $ do
180
- a <- Hedgehog. forAll (Gen. maybe (Vector. fromList <$> (Gen. list (Range. linear 0 10 ) textGen)))
181
+ nullable <- Hedgehog. forAll (Gen. maybe (Vector. fromList <$> (Gen. list (Range. linear 0 10 ) textGen)))
182
+ nonnull <- Hedgehog. forAll (Vector. fromList <$> (Gen. list (Range. linear 0 10 ) textGen))
181
183
182
- [MkTbl692 rowId v] <-
183
- liftIO . runBeamPostgres conn $
184
- runInsertReturningList $ insert (_myTable myDB) $ insertExpressions [ MkTbl692 default_ (val_ a) ]
185
- v === a
184
+ [MkTbl692 rowId v vnull] <-
185
+ liftIO . runBeamPostgres conn
186
+ $ runInsertReturningList
187
+ $ insert (_myTable myDB)
188
+ $ insertExpressions [ MkTbl692 default_ (val_ nonnull) (val_ nullable) ]
186
189
187
- Just (MkTbl692 _ v') <-
188
- liftIO . runBeamPostgres conn $
189
- runSelectReturningOne (lookup_ (_myTable myDB) (Tbl692Key rowId))
190
- v' === a
190
+ v === nonnull
191
+ vnull === nullable
192
+
193
+ Just (MkTbl692 _ v' vnull') <-
194
+ liftIO . runBeamPostgres conn
195
+ $ runSelectReturningOne (lookup_ (_myTable myDB) (Tbl692Key rowId))
196
+ v' === nonnull
197
+ vnull' === nullable
191
198
192
199
assertBool " Hedgehog test failed" passes
193
200
where
@@ -199,14 +206,17 @@ marshalTest692 postgresConn =
199
206
modifyTableFields
200
207
tableModification {
201
208
myid = fieldNamed " myid" ,
202
- mycolumn = fieldNamed " mycolumn"
209
+ mycolumn = fieldNamed " mycolumn" ,
210
+ mynullablecolumn = fieldNamed " mynullablecolumn"
203
211
}
204
212
}
205
213
206
214
data Tbl692 f
207
215
= MkTbl692
208
- { myid :: C f (SqlSerial Int32 )
209
- , mycolumn :: C f (Maybe (Vector. Vector T. Text )) }
216
+ { myid :: C f (SqlSerial Int32 )
217
+ , mycolumn :: C f (Vector. Vector T. Text )
218
+ , mynullablecolumn :: C f (Maybe (Vector. Vector T. Text ))
219
+ }
210
220
deriving (Generic , Beamable )
211
221
212
222
deriving instance Show (Tbl692 Identity )
0 commit comments