| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hmssql.Tds.Scalar
Description
The pure conversions of SQL Server's scalar values, and the type checks the field decoders make.
A reader is given exactly its value's bytes, whether they lay in one packet
or several, so it knows nothing about packets, and a wrong length is an
ordinary Left. Offsets into the bytes stay inside this module.
Synopsis
- integerValue :: TypeInfo -> ValueReader Int64
- integerAt :: Bool -> ValueReader Int64
- bitValue :: ValueReader Bool
- readFloating :: ValueReader Double
- float32Value :: ValueReader Float
- decimalValue :: TypeInfo -> ValueReader Decimal
- dayTimeValue :: (Day -> Int64 -> a) -> TypeInfo -> ValueReader a
- localTimeValue :: TypeInfo -> ValueReader LocalTime
- data SelectedReader = SelectedReader !(ValueReader SqlValue)
- selectSqlValueReader :: TdsContext -> TypeInfo -> SelectedReader
- readSqlVariant :: TdsContext -> ValueReader SqlValue
- columnTextDecoder :: TypeInfo -> Either String (ValueReader Text)
- decodeColumnText :: TypeInfo -> ByteString -> Either String Text
- textValue :: TextEncoding -> ValueReader Text
- data TextEncoding
- textEncodingOf :: TypeInfo -> Either String TextEncoding
- ansiCollation :: TypeInfo -> Maybe Collation
- hasDataType :: (SqlDataType -> Bool) -> TypeInfo -> Bool
- rejectAs :: String -> TypeInfo -> String
- unsupportedUdt :: TypeInfo -> String -> String
- isIntegerType :: TypeInfo -> Bool
- unsignedByteType :: TypeInfo -> Bool
- isFloatType :: TypeInfo -> Bool
- isDecimalType :: TypeInfo -> Bool
- isMoneyType :: TypeInfo -> Bool
- isUnicodeType :: TypeInfo -> Bool
- isAnsiType :: TypeInfo -> Bool
- isBinaryType :: TypeInfo -> Bool
- isLocalTimeType :: TypeInfo -> Bool
- isDateTimeOffsetType :: TypeInfo -> Bool
Scalar value readers
integerValue :: TypeInfo -> ValueReader Int64 Source #
The value of an integer-typed column (isIntegerType). Integers
arrive as 1, 2, 4 or 8 little-endian bytes; the value's own length is
authoritative. A tinyint is unsigned on the wire.
integerAt :: Bool -> ValueReader Int64 Source #
integerValue, given whether a one-byte value is unsigned.
bitValue :: ValueReader Bool Source #
bit.
readFloating :: ValueReader Double Source #
real or float, by the value's length.
float32Value :: ValueReader Float Source #
real; a float value is refused rather than narrowed.
decimalValue :: TypeInfo -> ValueReader Decimal Source #
A decimal or numeric at the type's precision and scale, a money
type, or an integer type, as a Decimal.
dayTimeValue :: (Day -> Int64 -> a) -> TypeInfo -> ValueReader a Source #
A date-and-time type's value, given to the function as the day and the picoseconds since midnight.
localTimeValue :: TypeInfo -> ValueReader LocalTime Source #
dayTimeValue as a LocalTime.
data SelectedReader Source #
The SqlValue reader of a column's type, which selectSqlValueReader
chooses once per column.
Constructors
| SelectedReader !(ValueReader SqlValue) |
selectSqlValueReader :: TdsContext -> TypeInfo -> SelectedReader Source #
The reader of a column's values as SqlValue, by the column's type; for
a type it can't decode, a reader that fails on every value.
readSqlVariant :: TdsContext -> ValueReader SqlValue Source #
MS-TDS 2.2.5.5.4 sql_variant: base type, property bytes, then the value using the rest of the buffer. The number of property bytes is fixed by the base type.
Character values
columnTextDecoder :: TypeInfo -> Either String (ValueReader Text) Source #
Compile a decoder for a character column. Unicode types are UTF-16LE. Single-byte types are decoded according to their collation's code page (see Hmssql.Tds.CodePage); a collation whose code page hmssql can't decode (a double-byte code page, or an unknown collation) is rejected.
decodeColumnText :: TypeInfo -> ByteString -> Either String Text Source #
Decode a character value; see columnTextDecoder.
textValue :: TextEncoding -> ValueReader Text Source #
A character value as Text, in the column's encoding.
data TextEncoding Source #
How a character column's values are encoded: UTF-16LE, or a single-byte code page's codec, chosen by the collation once per column.
textEncodingOf :: TypeInfo -> Either String TextEncoding Source #
The TextEncoding of a character column, or why it can't be decoded
as Text (not a character type, or a collation whose code page hmssql
can't decode).
Type selection and errors
hasDataType :: (SqlDataType -> Bool) -> TypeInfo -> Bool Source #
Whether a wire type's SQL data type satisfies the predicate.
rejectAs :: String -> TypeInfo -> String Source #
The message for a column of a type the decoder of this name doesn't accept.
unsupportedUdt :: TypeInfo -> String -> String Source #
The message for a CLR user-defined type, which hmssql doesn't decode.
isIntegerType :: TypeInfo -> Bool Source #
The integer types and bit.
unsignedByteType :: TypeInfo -> Bool Source #
Whether an integer type's one-byte values are unsigned (tinyint).
isFloatType :: TypeInfo -> Bool Source #
float and real.
isDecimalType :: TypeInfo -> Bool Source #
decimal and numeric.
isMoneyType :: TypeInfo -> Bool Source #
money and smallmoney.
isUnicodeType :: TypeInfo -> Bool Source #
The UTF-16 character types, xml included; the single-byte character
types; and the binary types.
isAnsiType :: TypeInfo -> Bool Source #
The UTF-16 character types, xml included; the single-byte character
types; and the binary types.
isBinaryType :: TypeInfo -> Bool Source #
The UTF-16 character types, xml included; the single-byte character
types; and the binary types.
isLocalTimeType :: TypeInfo -> Bool Source #
The date and time types without an offset, date included.
isDateTimeOffsetType :: TypeInfo -> Bool Source #
datetimeoffset.