Skip to content

Commit

Permalink
Add support for TDS ORDER token used for ordering result sets
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlan authored and wonderix committed Nov 8, 2023
1 parent a1b8fe3 commit 6ed663a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/tds/token.cr
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,15 @@ module TDS::Token
end
end

alias Token = InfoOrError | MetaData | LogInAck | Row | Done | DoneInProc | EnvChange | ReturnStatus | Param
struct Order
def self.from_io(io : IO)
len = UInt16.from_io(io, ENCODING)
io.seek(len, IO::Seek::Current)
Order.new
end
end

alias Token = InfoOrError | MetaData | LogInAck | Row | Done | DoneInProc | EnvChange | ReturnStatus | Param | Order

private class Iterator
include ::Iterator(Token)
Expand Down Expand Up @@ -224,6 +232,8 @@ module TDS::Token
ReturnStatus.from_io(@io)
when Type::PARAM
Param.from_io(@io)
when Type::ORDER
Order.from_io(@io)
else
raise ProtocolError.new("Invalid token #{"0x%02x" % type} at position #{"0x%04x" % @io.pos}")
end
Expand Down

0 comments on commit 6ed663a

Please sign in to comment.