Skip to content

Commit 3a1851b

Browse files
committed
Make getOrganizationsBy generic
1 parent 722af9b commit 3a1851b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

squeal-postgresql/exe/Example.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#-}
1111

1212
{-# LANGUAGE ScopedTypeVariables #-}
13-
13+
{-# LANGUAGE AllowAmbiguousTypes #-}
1414

1515
module Main (main, main2, upsertUser) where
1616

@@ -128,6 +128,7 @@ getOrganizations = select_
128128

129129
getOrganizationsBy ::
130130
forall pgty hsty.
131+
NullPG hsty ~ NotNull pgty =>
131132
Condition
132133
'Ungrouped
133134
'[]
@@ -205,14 +206,14 @@ session = do
205206
liftIO $ print (organizationRows :: [Organization])
206207

207208
organizationsResult2 <- runQueryParams
208-
(getOrganizationsBy ((#o ! #id) .== param @1)) (Only (1 :: Int32))
209+
(getOrganizationsBy @'PGint4 @Int32 ((#o ! #id) .== param @1)) (Only (1 :: Int32))
209210
organizationRows2 <- getRows organizationsResult2
210211
liftIO $ print (organizationRows2 :: [Organization])
211212

212213
organizationsResult3 <- runQueryParams
213-
(getOrganizationsBy ((#o ! #name) .== param @1)) (Only ("ACME" :: Text))
214+
(getOrganizationsBy @'PGtext @Text ((#o ! #name) .== param @1)) (Only ("Haskell Foundation" :: Text))
214215
organizationRows3 <- getRows organizationsResult3
215-
liftIO $ print (organizationRows2 :: [Organization])
216+
liftIO $ print (organizationRows3 :: [Organization])
216217

217218
main :: IO ()
218219
main = do

0 commit comments

Comments
 (0)