Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion src/Database/PostgreSQL/Simple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module Database.PostgreSQL.Simple
, Binary(..)
, Only(..)
, (:.)(..)
, LSN(..)
-- ** Exceptions
, SqlError(..)
, PQ.ExecStatus(..)
Expand Down Expand Up @@ -132,7 +133,7 @@ import Database.PostgreSQL.Simple.FromRow (FromRow(..))
import Database.PostgreSQL.Simple.ToField (Action(..))
import Database.PostgreSQL.Simple.ToRow (ToRow(..))
import Database.PostgreSQL.Simple.Types
( Binary(..), In(..), Only(..), Query(..), (:.)(..) )
( Binary(..), In(..), Only(..), Query(..), (:.)(..), LSN(..) )
import Database.PostgreSQL.Simple.Internal as Base
import Database.PostgreSQL.Simple.Internal.PQResultUtils
import Database.PostgreSQL.Simple.Transaction
Expand Down
3 changes: 3 additions & 0 deletions src/Database/PostgreSQL/Simple/FromField.hs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ instance FromField LocalTimestamp where
instance FromField Date where
fromField = ff $(inlineTypoid TI.date) "Date" parseDate

instance FromField LSN where
fromField = ff $(inlineTypoid TI.pg_lsn) "LSN" (Right . LSN)

ff :: PQ.Oid -> String -> (B8.ByteString -> Either String a)
-> Field -> Maybe B8.ByteString -> Conversion a
ff compatOid hsType parse f mstr =
Expand Down
4 changes: 4 additions & 0 deletions src/Database/PostgreSQL/Simple/ToField.hs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ instance ToField UUID where
instance ToField JSON.Value where
toField = toField . JSON.encode

instance ToField LSN where
toField (LSN bs) = Plain $ inQuotes $ byteString bs
{-# INLINE toField #-}

-- | Convert a Haskell value to a JSON 'JSON.Value' using
-- 'JSON.toJSON' and convert that to a field using 'toField'.
--
Expand Down
Loading