Copyright | Flipstone Technology Partners 2023 |
---|---|
License | MIT |
Stability | Stable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
The functions in this module are named with the intent that it is imported
qualified as SqlValue
.
Since: 1.0.0.0
Synopsis
- data SqlValue
- isSqlNull :: SqlValue -> Bool
- sqlNull :: SqlValue
- fromInt8 :: Int8 -> SqlValue
- toInt8 :: SqlValue -> Either String Int8
- fromInt16 :: Int16 -> SqlValue
- toInt16 :: SqlValue -> Either String Int16
- fromInt32 :: Int32 -> SqlValue
- toInt32 :: SqlValue -> Either String Int32
- fromInt64 :: Int64 -> SqlValue
- toInt64 :: SqlValue -> Either String Int64
- fromInt :: Int -> SqlValue
- toInt :: SqlValue -> Either String Int
- fromWord8 :: Word8 -> SqlValue
- toWord8 :: SqlValue -> Either String Word8
- fromWord16 :: Word16 -> SqlValue
- toWord16 :: SqlValue -> Either String Word16
- fromWord32 :: Word32 -> SqlValue
- toWord32 :: SqlValue -> Either String Word32
- fromWord64 :: Word64 -> SqlValue
- toWord64 :: SqlValue -> Either String Word64
- fromWord :: Word -> SqlValue
- toWord :: SqlValue -> Either String Word
- fromDouble :: Double -> SqlValue
- toDouble :: SqlValue -> Either String Double
- fromBool :: Bool -> SqlValue
- toBool :: SqlValue -> Either String Bool
- fromText :: Text -> SqlValue
- toText :: SqlValue -> Either String Text
- fromDay :: Day -> SqlValue
- toDay :: SqlValue -> Either String Day
- fromUTCTime :: UTCTime -> SqlValue
- toUTCTime :: SqlValue -> Either String UTCTime
- fromLocalTime :: LocalTime -> SqlValue
- toLocalTime :: SqlValue -> Either String LocalTime
- fromRawBytes :: ByteString -> SqlValue
- fromRawBytesNullable :: Maybe ByteString -> SqlValue
- toPgValue :: SqlValue -> Maybe PgTextFormatValue
Documentation
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
isSqlNull :: SqlValue -> Bool Source #
Checks whether the SqlValue
represents a SQL NULL value in the database.
Since: 1.0.0.0
A value of SqlValue
that will be interpreted as a SQL NULL value when
passed to the database.
Since: 1.0.0.0
fromInt16 :: Int16 -> SqlValue Source #
Encodes an Int16
value for use with the database.
Since: 1.0.0.0
fromInt32 :: Int32 -> SqlValue Source #
Encodes an Int32
value for use with the database.
Since: 1.0.0.0
fromInt64 :: Int64 -> SqlValue Source #
Encodes an Int64
value for use with the database.
Since: 1.0.0.0
fromWord8 :: Word8 -> SqlValue Source #
Encodes a Word8
value for use with the database.
Since: 1.0.0.0
fromWord16 :: Word16 -> SqlValue Source #
Encodes a Word16
value for use with the database.
Since: 1.0.0.0
fromWord32 :: Word32 -> SqlValue Source #
Encodes a Word32
value for use with the database.
Since: 1.0.0.0
fromWord64 :: Word64 -> SqlValue Source #
Encodes a Word64
value for use with the database.
Since: 1.0.0.0
fromDouble :: Double -> SqlValue Source #
Encodes a Double
value for use with the database.
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
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
fromUTCTime :: UTCTime -> SqlValue Source #
Encodes a UTCTime
in ISO-8601 format for use with the database.
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
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