Skip to main content

Module types

Module types 

Source
Expand description

TDS types: reading COLMETADATA and rows into Value, and encoding bound parameters on the way out.

SQL Server sends everything in binary, so unlike the PostgreSQL driver — which asks for text and parses it — this module owns a decoder per type. Two decisions are worth stating up front, because they look like omissions:

  • decimal, numeric and money come back as Value::Text. A decimal is an exact type; turning it into f64 would quietly lose the precision the column exists to preserve, and the framework has no decimal type yet.
  • date, time, datetime, datetime2 and datetimeoffset come back as text too, in ISO 8601 order. The framework has no date type yet, and the PostgreSQL driver already keeps timestamps as text, so a model that reads a timestamp as String behaves the same on both databases.

sql_variant is the one type this module cannot promise: it is decoded when its base type is one of the common scalars and returned as NULL otherwise, having consumed exactly the right number of bytes so the token stream stays aligned.

Structs§

Collation
The five collation bytes that follow every character type.
Column
One column of a result set.
TypeInfo
A column’s declared type, as COLMETADATA describes it.

Enums§

LengthStyle
How the value that follows a TYPE_INFO announces its own length.

Constants§

BIGBINARYTYPE
BIGCHARTYPE
BIGVARBINARYTYPE
BIGVARCHARTYPE
BINARYTYPE
BITNTYPE
BITTYPE
CHARTYPE
DATENTYPE
DATETIM4TYPE
DATETIME2NTYPE
DATETIMEOFFSETNTYPE
DATETIMETYPE
DATETIMNTYPE
DECIMALNTYPE
DECIMALTYPE
FLT4TYPE
FLT8TYPE
FLTNTYPE
GUIDTYPE
IMAGETYPE
INT1TYPE
INT2TYPE
INT4TYPE
INT8TYPE
INTNTYPE
MONEY4TYPE
MONEYNTYPE
MONEYTYPE
NCHARTYPE
NTEXTTYPE
NULLTYPE
NUMERICNTYPE
NUMERICTYPE
NVARCHARTYPE
SSVARIANTTYPE
TEXTTYPE
TIMENTYPE
VARBINARYTYPE
VARCHARTYPE
XMLTYPE

Functions§

as_json
A JSON document read back out of an nvarchar(max) column.
declare
The @params argument of sp_executesql: @P1 bigint, @P2 nvarchar(max).
encode
Encode one bound parameter as TYPE_INFO followed by its value.
parse_column_metadata
Read a COLMETADATA token body.
parse_type_info
Read a TYPE_INFO: the type byte and whatever describes its size.
read_nbc_row
Read one NBCROW token — a “null bitmap compressed” row.
read_row
Read one ROW token: every column, in order.
read_value
Read one value, given the type its column was declared with.