Safe Haskell | Safe-Inferred |
---|---|
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 :: forall b. 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 #
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 #
Constructors
StructValue | |
Fields
|
Instances
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 # | |
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 # | |
ToField (StructValue FieldValue) Source # | |
Defined in Database.DuckDB.Simple.ToField Methods | |
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 #
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 #
Constructors
UnionValue | |
Fields
|
Instances
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 # | |
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 # | |
ToField (UnionValue FieldValue) Source # | |
Defined in Database.DuckDB.Simple.ToField Methods | |
Eq a => Eq (UnionValue a) Source # | |
Defined in Database.DuckDB.Simple.LogicalRep |
data LogicalTypeRep Source #
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 # |
Constructors
BitString | |
Fields
|
Instances
Show BitString Source # | |
FromField BitString Source # | |
Defined in Database.DuckDB.Simple.FromField Methods | |
DuckDBColumnType BitString Source # | |
Defined in Database.DuckDB.Simple.ToField | |
ToField BitString Source # | |
Defined in Database.DuckDB.Simple.ToField Methods toField :: BitString -> FieldBinding Source # | |
Eq BitString Source # | |
bsFromBool :: [Bool] -> BitString Source #
Instances
Num BigNum Source # | |
Show BigNum Source # | |
FromField BigNum Source # | |
Defined in Database.DuckDB.Simple.FromField Methods | |
DuckDBColumnType BigNum Source # | |
Defined in Database.DuckDB.Simple.ToField | |
ToField BigNum Source # | |
Defined in Database.DuckDB.Simple.ToField Methods toField :: BigNum -> FieldBinding 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 #
Constructors
DecimalValue | |
Fields
|
Instances
Show DecimalValue Source # | |
Defined in Database.DuckDB.Simple.FromField Methods showsPrec :: Int -> DecimalValue -> ShowS # show :: DecimalValue -> String # showList :: [DecimalValue] -> ShowS # | |
FromField DecimalValue Source # | |
Defined in Database.DuckDB.Simple.FromField Methods | |
Eq DecimalValue Source # | |
Defined in Database.DuckDB.Simple.FromField |
data IntervalValue Source #
Constructors
IntervalValue | |
Fields
|
Instances
Show IntervalValue Source # | |
Defined in Database.DuckDB.Simple.FromField Methods showsPrec :: Int -> IntervalValue -> ShowS # show :: IntervalValue -> String # showList :: [IntervalValue] -> ShowS # | |
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 # | |
Eq IntervalValue Source # | |
Defined in Database.DuckDB.Simple.FromField Methods (==) :: IntervalValue -> IntervalValue -> Bool # (/=) :: IntervalValue -> IntervalValue -> Bool # |
data TimeWithZone Source #
Constructors
TimeWithZone | |
Fields |
Instances
Show TimeWithZone Source # | |
Defined in Database.DuckDB.Simple.FromField Methods showsPrec :: Int -> TimeWithZone -> ShowS # show :: TimeWithZone -> String # showList :: [TimeWithZone] -> ShowS # | |
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 # | |
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 # | |
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
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 #