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
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,11 @@ parse =

parseInfinities :: A.Parser Interval
parseInfinities =
-- Both `-infinity` and `infinity` are new as of PostgreSQL 17.0.
-- `infinity` is new as of PostgreSQL 17.0.
-- https://www.postgresql.org/message-id/E1r2rB1-005PHm-UL%40gemulon.postgresql.org
A.choice
[ MkInterval minBound minBound minBound <$ "-infinity",
MkInterval maxBound maxBound maxBound <$ "+infinity",
MkInterval maxBound maxBound maxBound <$ "infinity"
]

Expand Down
6 changes: 5 additions & 1 deletion source/test-suite/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,14 @@ spec = H.describe "Database.PostgreSQL.Simple.Interval" $ do
let actual = Attoparsec.parseOnly I.parse "invalid"
actual `H.shouldBe` Left "Failed reading: empty"

H.it "succeeds with positive infinity" $ do
H.it "succeeds with implicit positive infinity" $ do
let actual = Attoparsec.parseOnly I.parse "infinity"
actual `H.shouldBe` Right (I.MkInterval maxBound maxBound maxBound)

H.it "succeeds with explicit positive infinity" $ do
let actual = Attoparsec.parseOnly I.parse "+infinity"
actual `H.shouldBe` Right (I.MkInterval maxBound maxBound maxBound)

H.it "succeeds with negative infinity" $ do
let actual = Attoparsec.parseOnly I.parse "-infinity"
actual `H.shouldBe` Right (I.MkInterval minBound minBound minBound)
Expand Down