Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions postgresql-simple-interval.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
16 changes: 6 additions & 10 deletions source/test-suite/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading