orville-postgresql-1.0.0.0: A Haskell library for PostgreSQL
CopyrightFlipstone Technology Partners 2023
LicenseMIT
StabilityStable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Orville.PostgreSQL.Raw.SqlValue

Description

The functions in this module are named with the intent that it is imported qualified as SqlValue.

Since: 1.0.0.0

Synopsis

Documentation

data SqlValue Source #

SqlValue represents a value that is in encoded format for use with LibPQ. It is used both for values passed to LibPQ and values parsed from LibPQ. The conversion functions in Orville.PostgreSQL.Raw.SqlValue can be used to convert to and from the value.

Since: 1.0.0.0

Instances

Instances details
Eq SqlValue Source # 
Instance details

Defined in Orville.PostgreSQL.Raw.SqlValue

isSqlNull :: SqlValue -> Bool Source #

Checks whether the SqlValue represents a SQL NULL value in the database.

Since: 1.0.0.0

sqlNull :: SqlValue Source #

A value of SqlValue that will be interpreted as a SQL NULL value when passed to the database.

Since: 1.0.0.0

fromInt8 :: Int8 -> SqlValue Source #

Encodes an Int8 value for use with the database.

Since: 1.0.0.0

toInt8 :: SqlValue -> Either String Int8 Source #

Attempts to decode a SqlValue as a Haskell Int8 value. If decoding fails, Nothing is returned.

Since: 1.0.0.0

fromInt16 :: Int16 -> SqlValue Source #

Encodes an Int16 value for use with the database.

Since: 1.0.0.0

toInt16 :: SqlValue -> Either String Int16 Source #

Attempts to decode a SqlValue as a Haskell Int16 value. If decoding fails, Nothing is returned.

Since: 1.0.0.0

fromInt32 :: Int32 -> SqlValue Source #

Encodes an Int32 value for use with the database.

Since: 1.0.0.0

toInt32 :: SqlValue -> Either String Int32 Source #

Attempts to decode a SqlValue as a Haskell Int32 value. If decoding fails, Nothing is returned.

Since: 1.0.0.0

fromInt64 :: Int64 -> SqlValue Source #

Encodes an Int64 value for use with the database.

Since: 1.0.0.0

toInt64 :: SqlValue -> Either String Int64 Source #

Attempts to decode a SqlValue as a Haskell Int value. If decoding fails, Nothing is returned.

Since: 1.0.0.0

fromInt :: Int -> SqlValue Source #

Encodes an Int value for use with the database.

Since: 1.0.0.0

toInt :: SqlValue -> Either String Int Source #

Attempts to decode a SqlValue as a Haskell Int value. If decoding fails, Nothing is returned.

Since: 1.0.0.0

fromWord8 :: Word8 -> SqlValue Source #

Encodes a Word8 value for use with the database.

Since: 1.0.0.0

toWord8 :: SqlValue -> Either String Word8 Source #

Attempts to decode a SqlValue as a Haskell Word8 value. If decoding fails, Nothing is returned.

Since: 1.0.0.0

fromWord16 :: Word16 -> SqlValue Source #

Encodes a Word16 value for use with the database.

Since: 1.0.0.0

toWord16 :: SqlValue -> Either String Word16 Source #

Attempts to decode a SqlValue as a Haskell Word16 value. If decoding fails, Nothing is returned.

Since: 1.0.0.0

fromWord32 :: Word32 -> SqlValue Source #

Encodes a Word32 value for use with the database.

Since: 1.0.0.0

toWord32 :: SqlValue -> Either String Word32 Source #

Attempts to decode a SqlValue as a Haskell Word32 value. If decoding fails, Nothing is returned.

Since: 1.0.0.0

fromWord64 :: Word64 -> SqlValue Source #

Encodes a Word64 value for use with the database.

Since: 1.0.0.0

toWord64 :: SqlValue -> Either String Word64 Source #

Attempts to decode a SqlValue as a Haskell Word64 value. If decoding fails, Nothing is returned.

Since: 1.0.0.0

fromWord :: Word -> SqlValue Source #

Encodes a Word value for use with the database.

Since: 1.0.0.0

toWord :: SqlValue -> Either String Word Source #

Attempts to decode a SqlValue as a Haskell Word value. If decoding fails, Nothing is returned.

Since: 1.0.0.0

fromDouble :: Double -> SqlValue Source #

Encodes a Double value for use with the database.

Since: 1.0.0.0

toDouble :: SqlValue -> Either String Double Source #

Attempts to decode a SqlValue as a Haskell Double value. If decoding fails, Nothing is returned.

Since: 1.0.0.0

fromBool :: Bool -> SqlValue Source #

Encodes a Bool value for use with the database.

Since: 1.0.0.0

toBool :: SqlValue -> Either String Bool Source #

Attempts to decode a SqlValue as a Haskell Bool value. If decoding fails, Nothing is returned.

Since: 1.0.0.0

fromText :: Text -> SqlValue Source #

Encodes a Text value as UTF-8 so that it can be used with the database.

Since: 1.0.0.0

toText :: SqlValue -> Either String Text Source #

Attempts to decode a SqlValue as UTF-8 text. If the decoding fails, Nothing is returned.

Note: This decoding _only_ fails if the bytes returned from the database are not a valid UTF-8 sequence of bytes. Otherwise it always succeeds.

Since: 1.0.0.0

fromDay :: Day -> SqlValue Source #

Encodes a Day value as text in YYYY-MM-DD format so that it can be used with the database.

Since: 1.0.0.0

toDay :: SqlValue -> Either String Day Source #

Attempts to decode a SqlValue as into a Day value by parsing it from YYYY-MM-DD format. If the decoding fails, Nothing is returned.

Since: 1.0.0.0

fromUTCTime :: UTCTime -> SqlValue Source #

Encodes a UTCTime in ISO-8601 format for use with the database.

Since: 1.0.0.0

toUTCTime :: SqlValue -> Either String UTCTime Source #

Attempts to decode a SqlValue as a UTCTime formatted in ISO-8601 format with time zone. If the decoding fails, Nothing is returned.

Since: 1.0.0.0

fromLocalTime :: LocalTime -> SqlValue Source #

Encodes a LocalTime in ISO-8601 format for use with the database.

Since: 1.0.0.0

toLocalTime :: SqlValue -> Either String LocalTime Source #

Attempts to decode a SqlValue as a LocalTime formatted in ISO-8601 format in the default locale. If the decoding fails, Nothing is returned.

Since: 1.0.0.0

fromRawBytes :: ByteString -> SqlValue Source #

Creates a SqlValue from a raw bytestring as if the bytes had been returned by the database. This function does not interpret the bytes in any way, but using decode functions on them might fail depending on whether the bytes can be parsed as the requested type.

Note: A value to represent a SQL NULL cannot be constructed using this function. See fromRawBytesNullable for how to represent a nullable raw value.

Since: 1.0.0.0

fromRawBytesNullable :: Maybe ByteString -> SqlValue Source #

Creates a SqlValue from a raw bytestring. If Nothing is specified as the input parameter then the resulting SqlValue will represent a NULL value in SQL. Otherwise, the bytes given are used in the same way as fromRawBytes.

Since: 1.0.0.0

toPgValue :: SqlValue -> Maybe PgTextFormatValue Source #

Converts a SqlValue to its underlying raw bytes as it will be represented when sent to the database. The output should be recognizable as similar to values you would write in a query. If the value represents a SQL NULL value, Nothing is returned.

Since: 1.0.0.0