Skip to content

Commit c82353c

Browse files
committed
Fix bug where last result set was omitted if DONE token was in a separate packet
1 parent cd420db commit c82353c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Sources/CosmoMSSQL/TDS/TDSDecoder.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,11 @@ struct TDSTokenDecoder {
186186
let _: UInt16 = buf.readInteger(endianness: .little), // curCmd
187187
let count: UInt64 = buf.readInteger(endianness: .little) // rowCount (8 bytes in TDS 7.2+)
188188
else { throw TDSError.incomplete }
189-
// Flush current rows into resultSets on any DONE token
190-
if !currentRows.isEmpty {
189+
// Flush current rows into resultSets on any DONE token if we have columns (i.e. a result set was started)
190+
if !columns.isEmpty {
191191
resultSets.append(currentRows)
192192
currentRows = []
193+
columns = [] // Reset columns for next result set
193194
}
194195
// Only trust the rowcount when the DONE_COUNT bit (0x10) is set
195196
if status & 0x10 != 0 {

0 commit comments

Comments
 (0)