@@ -23,6 +23,8 @@ import Data.Aeson
2323import Data.ByteString (ByteString)
2424import qualified Data.ByteString as B
2525import qualified Data.ByteString.Lazy.Char8 as BL
26+import Data.CaseInsensitive (CI)
27+import qualified Data.CaseInsensitive as CI
2628import Data.Map (Map)
2729import qualified Data.Map as Map
2830import Data.Text(Text)
@@ -50,6 +52,7 @@ tests env = testGroup "tests"
5052 , testCase "Array" . testArray
5153 , testCase "Array of nullables" . testNullableArray
5254 , testCase "HStore" . testHStore
55+ , testCase "citext" . testCIText
5356 , testCase "JSON" . testJSON
5457 , testCase "Savepoint" . testSavepoint
5558 , testCase "Unicode" . testUnicode
@@ -203,6 +206,19 @@ testHStore TestEnv{..} = do
203206 m' <- query conn "SELECT ?::hstore" m
204207 [m] @?= m'
205208
209+testCIText :: TestEnv -> Assertion
210+testCIText TestEnv{..} = do
211+ execute_ conn "CREATE EXTENSION IF NOT EXISTS citext"
212+ roundTrip (CI.mk "")
213+ roundTrip (CI.mk "UPPERCASE")
214+ roundTrip (CI.mk "lowercase")
215+ where
216+ roundTrip :: (CI Text) -> Assertion
217+ roundTrip cit = do
218+ let toPostgres = Only cit
219+ fromPostgres <- query conn "SELECT ?::citext" toPostgres
220+ [toPostgres] @?= fromPostgres
221+
206222testJSON :: TestEnv -> Assertion
207223testJSON TestEnv{..} = do
208224 roundTrip (Map.fromList [] :: Map Text Text)