| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.DuckDB.Simple.FromField
Description
Synopsis
- data Field = Field {
- fieldName :: Text
- fieldIndex :: Int
- fieldValue :: FieldValue
- data FieldValue
- = FieldNull
- | FieldInt8 Int8
- | FieldInt16 Int16
- | FieldInt32 Int32
- | FieldInt64 Int64
- | FieldWord8 Word8
- | FieldWord16 Word16
- | FieldWord32 Word32
- | FieldWord64 Word64
- | FieldUUID UUID
- | FieldFloat Float
- | FieldDouble Double
- | FieldText Text
- | FieldBool Bool
- | FieldBlob ByteString
- | FieldDate Day
- | FieldTime TimeOfDay
- | FieldTimestamp LocalTime
- | FieldInterval IntervalValue
- | FieldHugeInt Integer
- | FieldUHugeInt Integer
- | FieldDecimal DecimalValue
- | FieldTimestampTZ UTCTime
- | FieldTimeTZ TimeWithZone
- | FieldBit BitString
- | FieldBigNum BigNum
- | FieldEnum Word32
- | FieldArray (Array Int FieldValue)
- | FieldList [FieldValue]
- | FieldMap [(FieldValue, FieldValue)]
- | FieldStruct (StructValue FieldValue)
- | FieldUnion (UnionValue FieldValue)
- data StructField a = StructField {
- structFieldName :: !Text
- structFieldValue :: !a
- data StructValue a = StructValue {
- structValueFields :: !(Array Int (StructField a))
- structValueTypes :: !(Array Int (StructField LogicalTypeRep))
- structValueIndex :: !(Map Text Int)
- data UnionMemberType = UnionMemberType {}
- data UnionValue a = UnionValue {
- unionValueIndex :: !Word16
- unionValueLabel :: !Text
- unionValuePayload :: !a
- unionValueMembers :: !(Array Int UnionMemberType)
- data LogicalTypeRep
- = LogicalTypeScalar DuckDBType
- | LogicalTypeDecimal !Word8 !Word8
- | LogicalTypeList LogicalTypeRep
- | LogicalTypeArray LogicalTypeRep !Word64
- | LogicalTypeMap LogicalTypeRep LogicalTypeRep
- | LogicalTypeStruct !(Array Int (StructField LogicalTypeRep))
- | LogicalTypeUnion !(Array Int UnionMemberType)
- | LogicalTypeEnum !(Array Int Text)
- data BitString = BitString {
- padding :: !Word8
- bits :: !ByteString
- bsFromBool :: [Bool] -> BitString
- newtype BigNum = BigNum Integer
- fromBigNumBytes :: [Word8] -> Integer
- toBigNumBytes :: Integer -> [Word8]
- data DecimalValue = DecimalValue {
- decimalWidth :: !Word8
- decimalScale :: !Word8
- decimalInteger :: !Integer
- data IntervalValue = IntervalValue {
- intervalMonths :: !Int32
- intervalDays :: !Int32
- intervalMicros :: !Int64
- data TimeWithZone = TimeWithZone {}
- data ResultError
- = Incompatible {
- errSQLType :: Text
- errSQLField :: Text
- errHaskellType :: Text
- errMessage :: Text
- | UnexpectedNull {
- errSQLType :: Text
- errSQLField :: Text
- errHaskellType :: Text
- errMessage :: Text
- | ConversionFailed {
- errSQLType :: Text
- errSQLField :: Text
- errHaskellType :: Text
- errMessage :: Text
- = Incompatible {
- type FieldParser a = Field -> Ok a
- class FromField a where
- fromField :: FieldParser a
- returnError :: Typeable b => (Text -> Text -> Text -> Text -> ResultError) -> Field -> Text -> Ok b
Documentation
Metadata for a single column in a row.
Constructors
| Field | |
Fields
| |
Instances
data FieldValue Source #
Internal representation of a column value.
Constructors
Instances
data StructField a Source #
A named field within a STRUCT-like value or type.
Constructors
| StructField | |
Fields
| |
Instances
| Show a => Show (StructField a) Source # | |
Defined in Database.DuckDB.Simple.LogicalRep Methods showsPrec :: Int -> StructField a -> ShowS # show :: StructField a -> String # showList :: [StructField a] -> ShowS # | |
| Eq a => Eq (StructField a) Source # | |
Defined in Database.DuckDB.Simple.LogicalRep Methods (==) :: StructField a -> StructField a -> Bool # (/=) :: StructField a -> StructField a -> Bool # | |
data StructValue a Source #
A fully materialized STRUCT value together with its type metadata.
Constructors
| StructValue | |
Fields
| |
Instances
| FromField (StructValue FieldValue) Source # | |
Defined in Database.DuckDB.Simple.FromField Methods | |
| DuckDBColumnType (StructValue FieldValue) Source # | |
Defined in Database.DuckDB.Simple.ToField Methods duckdbColumnTypeFor :: Proxy (StructValue FieldValue) -> Text Source # | |
| ToDuckValue (StructValue FieldValue) Source # | |
Defined in Database.DuckDB.Simple.ToField Methods toDuckValue :: StructValue FieldValue -> IO DuckDBValue Source # | |
| ToField (StructValue FieldValue) Source # | |
Defined in Database.DuckDB.Simple.ToField Methods | |
| Show a => Show (StructValue a) Source # | |
Defined in Database.DuckDB.Simple.LogicalRep Methods showsPrec :: Int -> StructValue a -> ShowS # show :: StructValue a -> String # showList :: [StructValue a] -> ShowS # | |
| Eq a => Eq (StructValue a) Source # | |
Defined in Database.DuckDB.Simple.LogicalRep Methods (==) :: StructValue a -> StructValue a -> Bool # (/=) :: StructValue a -> StructValue a -> Bool # | |
data UnionMemberType Source #
A named member within a UNION type.
Constructors
| UnionMemberType | |
Fields | |
Instances
| Show UnionMemberType Source # | |
Defined in Database.DuckDB.Simple.LogicalRep Methods showsPrec :: Int -> UnionMemberType -> ShowS # show :: UnionMemberType -> String # showList :: [UnionMemberType] -> ShowS # | |
| Eq UnionMemberType Source # | |
Defined in Database.DuckDB.Simple.LogicalRep Methods (==) :: UnionMemberType -> UnionMemberType -> Bool # (/=) :: UnionMemberType -> UnionMemberType -> Bool # | |
data UnionValue a Source #
A fully materialized UNION value together with its member metadata.
Constructors
| UnionValue | |
Fields
| |
Instances
| FromField (UnionValue FieldValue) Source # | |
Defined in Database.DuckDB.Simple.FromField Methods | |
| DuckDBColumnType (UnionValue FieldValue) Source # | |
Defined in Database.DuckDB.Simple.ToField Methods duckdbColumnTypeFor :: Proxy (UnionValue FieldValue) -> Text Source # | |
| ToDuckValue (UnionValue FieldValue) Source # | |
Defined in Database.DuckDB.Simple.ToField Methods toDuckValue :: UnionValue FieldValue -> IO DuckDBValue Source # | |
| ToField (UnionValue FieldValue) Source # | |
Defined in Database.DuckDB.Simple.ToField Methods | |
| Show a => Show (UnionValue a) Source # | |
Defined in Database.DuckDB.Simple.LogicalRep Methods showsPrec :: Int -> UnionValue a -> ShowS # show :: UnionValue a -> String # showList :: [UnionValue a] -> ShowS # | |
| Eq a => Eq (UnionValue a) Source # | |
Defined in Database.DuckDB.Simple.LogicalRep | |
data LogicalTypeRep Source #
A Haskell description of a DuckDB logical type tree.
Constructors
Instances
| Show LogicalTypeRep Source # | |
Defined in Database.DuckDB.Simple.LogicalRep Methods showsPrec :: Int -> LogicalTypeRep -> ShowS # show :: LogicalTypeRep -> String # showList :: [LogicalTypeRep] -> ShowS # | |
| Eq LogicalTypeRep Source # | |
Defined in Database.DuckDB.Simple.LogicalRep Methods (==) :: LogicalTypeRep -> LogicalTypeRep -> Bool # (/=) :: LogicalTypeRep -> LogicalTypeRep -> Bool # | |
DuckDB BIT value represented as raw bytes plus left-padding bit count.
Constructors
| BitString | |
Fields
| |
Instances
| FromField BitString Source # | |
Defined in Database.DuckDB.Simple.FromField Methods | |
| DuckDBColumnType BitString Source # | |
Defined in Database.DuckDB.Simple.ToField | |
| ToDuckValue BitString Source # | |
Defined in Database.DuckDB.Simple.ToField Methods toDuckValue :: BitString -> IO DuckDBValue Source # | |
| ToField BitString Source # | |
Defined in Database.DuckDB.Simple.ToField Methods toField :: BitString -> FieldBinding Source # | |
| Show BitString Source # | |
| Eq BitString Source # | |
bsFromBool :: [Bool] -> BitString Source #
Construct a BitString from a list of Bools, where the first element
Arbitrary-precision integer wrapper used for DuckDB's BIGNUM type.
Instances
| FromField BigNum Source # | |
Defined in Database.DuckDB.Simple.FromField Methods | |
| DuckDBColumnType BigNum Source # | |
Defined in Database.DuckDB.Simple.ToField | |
| ToDuckValue BigNum Source # | |
Defined in Database.DuckDB.Simple.ToField Methods toDuckValue :: BigNum -> IO DuckDBValue Source # | |
| ToField BigNum Source # | |
Defined in Database.DuckDB.Simple.ToField Methods toField :: BigNum -> FieldBinding Source # | |
| Num BigNum Source # | |
| Show BigNum Source # | |
| Eq BigNum Source # | |
fromBigNumBytes :: [Word8] -> Integer Source #
Decode DuckDB’s BIGNUM blob (3-byte header + big-endian payload where negative magnitudes are
bitwise complemented) back into a Haskell Integer. We undo the complement when needed, then chunk
the remaining bytes into machine-word limbs (MSB chunk first) for integerFromWordList.
toBigNumBytes :: Integer -> [Word8] Source #
Encode an Integer into DuckDB’s BIGNUM blob layout: emit the 3-byte header
(sign bit plus payload length) followed by the magnitude bytes in the same
big-endian / complemented-on-negative form that DuckDB stores internally.
data DecimalValue Source #
Exact-width decimal payload plus its declared width and scale.
Constructors
| DecimalValue | |
Fields
| |
Instances
| FromField DecimalValue Source # | |
Defined in Database.DuckDB.Simple.FromField Methods | |
| Show DecimalValue Source # | |
Defined in Database.DuckDB.Simple.FromField Methods showsPrec :: Int -> DecimalValue -> ShowS # show :: DecimalValue -> String # showList :: [DecimalValue] -> ShowS # | |
| Eq DecimalValue Source # | |
Defined in Database.DuckDB.Simple.FromField | |
data IntervalValue Source #
DuckDB interval payload split into months, days, and microseconds.
Constructors
| IntervalValue | |
Fields
| |
Instances
| FromField IntervalValue Source # | |
Defined in Database.DuckDB.Simple.FromField Methods | |
| DuckValue IntervalValue Source # | |
Defined in Database.DuckDB.Simple.Generic Methods duckToField :: IntervalValue -> FieldValue Source # duckFromField :: FieldValue -> Either String IntervalValue Source # duckLogicalType :: Proxy IntervalValue -> LogicalTypeRep Source # | |
| Show IntervalValue Source # | |
Defined in Database.DuckDB.Simple.FromField Methods showsPrec :: Int -> IntervalValue -> ShowS # show :: IntervalValue -> String # showList :: [IntervalValue] -> ShowS # | |
| Eq IntervalValue Source # | |
Defined in Database.DuckDB.Simple.FromField Methods (==) :: IntervalValue -> IntervalValue -> Bool # (/=) :: IntervalValue -> IntervalValue -> Bool # | |
data TimeWithZone Source #
Time-of-day paired with its associated timezone offset.
Constructors
| TimeWithZone | |
Fields | |
Instances
| FromField TimeWithZone Source # | |
Defined in Database.DuckDB.Simple.FromField Methods | |
| DuckValue TimeWithZone Source # | |
Defined in Database.DuckDB.Simple.Generic Methods duckToField :: TimeWithZone -> FieldValue Source # duckFromField :: FieldValue -> Either String TimeWithZone Source # duckLogicalType :: Proxy TimeWithZone -> LogicalTypeRep Source # | |
| Show TimeWithZone Source # | |
Defined in Database.DuckDB.Simple.FromField Methods showsPrec :: Int -> TimeWithZone -> ShowS # show :: TimeWithZone -> String # showList :: [TimeWithZone] -> ShowS # | |
| Eq TimeWithZone Source # | |
Defined in Database.DuckDB.Simple.FromField | |
data ResultError Source #
Exception thrown if conversion from a SQL value to a Haskell value fails.
Constructors
| Incompatible | The SQL and Haskell types are not compatible. |
Fields
| |
| UnexpectedNull | A SQL |
Fields
| |
| ConversionFailed | The SQL value could not be parsed, or could not be represented as a valid Haskell value, or an unexpected low-level error occurred (e.g. mismatch between metadata and actual data in a row). |
Fields
| |
Instances
| Exception ResultError Source # | |
Defined in Database.DuckDB.Simple.FromField Methods toException :: ResultError -> SomeException # fromException :: SomeException -> Maybe ResultError # displayException :: ResultError -> String # backtraceDesired :: ResultError -> Bool # | |
| Show ResultError Source # | |
Defined in Database.DuckDB.Simple.FromField Methods showsPrec :: Int -> ResultError -> ShowS # show :: ResultError -> String # showList :: [ResultError] -> ShowS # | |
| Eq ResultError Source # | |
Defined in Database.DuckDB.Simple.FromField | |
type FieldParser a = Field -> Ok a Source #
Parser used by FromField instances and utilities such as
Database.DuckDB.Simple.FromRow.fieldWith. The supplied Field contains
column metadata and an already-decoded FieldValue; callers should return
Ok on success or Errors (typically wrapping a ResultError) when the
conversion fails.
class FromField a where Source #
Types that can be constructed from a DuckDB column.
Methods
fromField :: FieldParser a Source #