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,numericandmoneycome back asValue::Text. Adecimalis an exact type; turning it intof64would quietly lose the precision the column exists to preserve, and the framework has no decimal type yet.date,time,datetime,datetime2anddatetimeoffsetcome 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 asStringbehaves 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.
- Type
Info - A column’s declared type, as COLMETADATA describes it.
Enums§
- Length
Style - How the value that follows a TYPE_INFO announces its own length.
Constants§
- BIGBINARYTYPE
- BIGCHARTYPE
- BIGVARBINARYTYPE
- BIGVARCHARTYPE
- BINARYTYPE
- BITNTYPE
- BITTYPE
- CHARTYPE
- DATENTYPE
- DATETI
M4TYPE - DATETIM
E2NTYPE - DATETIMEOFFSETNTYPE
- DATETIMETYPE
- DATETIMNTYPE
- DECIMALNTYPE
- DECIMALTYPE
- FLT4TYPE
- FLT8TYPE
- FLTNTYPE
- GUIDTYPE
- IMAGETYPE
- INT1TYPE
- INT2TYPE
- INT4TYPE
- INT8TYPE
- INTNTYPE
- MONE
Y4TYPE - 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
@paramsargument ofsp_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.