diff --git a/postgresql-simple-interval.cabal b/postgresql-simple-interval.cabal index 7bfd821..e7d2d7b 100644 --- a/postgresql-simple-interval.cabal +++ b/postgresql-simple-interval.cabal @@ -28,7 +28,6 @@ common library base >=4.13 && <4.22, bytestring >=0.10.10 && <0.13, postgresql-simple ^>=0.7, - text >=1.2.4 && <1.3 || >=2.0 && <2.2, default-language: Haskell2010 ghc-options: @@ -64,6 +63,7 @@ library build-depends: persistent ^>=2.17, scientific ^>=0.3.8, + text >=1.2.4 && <1.3 || >=2.0 && <2.2, -- cabal-gild: discover source/library exposed-modules: @@ -74,7 +74,10 @@ library test-suite postgresql-simple-interval-test-suite import: executable - build-depends: hspec ^>=2.11.12 + build-depends: + hspec ^>=2.11.12, + postgresql-libpq ^>=0.11, + hs-source-dirs: source/test-suite main-is: Main.hs type: exitcode-stdio-1.0 diff --git a/source/test-suite/Main.hs b/source/test-suite/Main.hs index ba7f102..9b9dc51 100644 --- a/source/test-suite/Main.hs +++ b/source/test-suite/Main.hs @@ -8,12 +8,12 @@ import qualified Data.ByteString as ByteString import qualified Data.ByteString.Builder as Builder import qualified Data.ByteString.Lazy as LazyByteString import qualified Data.Int as Int -import qualified Data.Text as Text +import qualified Database.PostgreSQL.LibPQ as Pq import qualified Database.PostgreSQL.Simple as Postgres +import qualified Database.PostgreSQL.Simple.Internal as Postgres import qualified Database.PostgreSQL.Simple.Interval.Unstable as I import qualified Database.PostgreSQL.Simple.ToField as Postgres import qualified Test.Hspec as H -import qualified Text.Read as Read main :: IO () main = H.hspec spec @@ -165,14 +165,10 @@ spec = H.describe "Database.PostgreSQL.Simple.Interval" $ do case result of Right actual -> actual `H.shouldBe` [Postgres.Only interval] Left somePostgresqlException -> do - rows <- Postgres.query_ connection "select version()" - case rows of - Postgres.Only text : _ - | _ : rawVersion : _ <- Text.words text, - Just version <- Read.readMaybe (Text.unpack rawVersion), - version < (15 :: Double) -> - H.pendingWith $ "interval parsing broken with PostgreSQL version " <> show version - _ -> Exception.throwIO (somePostgresqlException :: Postgres.SomePostgreSqlException) + version <- Postgres.withConnection connection Pq.serverVersion + if version < 150000 + then H.pendingWith $ "interval parsing broken with PostgreSQL version " <> show version + else Exception.throwIO (somePostgresqlException :: Postgres.SomePostgreSqlException) data IntervalStyle = Iso8601