@@ -176,40 +176,46 @@ defmodule Tds.Tokens do
176176 end
177177 ## DONE
178178 defp decode_token ( << @ tds_token_done , status :: int16 , cur_cmd :: binary ( 2 ) , row_count :: little - size ( 8 ) - unit ( 8 ) , _tail :: binary >> , tokens ) do
179- case tokens do
180- [ done: done ] ->
181-
182- cond do
183- row_count > done . rows -> { [ done: % { status: status , cmd: cur_cmd , rows: row_count } ] ++ tokens , nil }
184- true -> { tokens , nil }
185- end
179+ case Keyword . get ( tokens , :done ) do
180+ nil ->
181+ { Keyword . put ( tokens , :done , % { status: status , cmd: cur_cmd , rows: row_count } ) , nil }
182+ % { rows: rows } when row_count > rows ->
183+ { Keyword . put ( tokens , :done , % { status: status , cmd: cur_cmd , rows: row_count } ) , nil }
184+ _ ->
186185 { tokens , nil }
187- _ -> { [ done: % { status: status , cmd: cur_cmd , rows: row_count } ] ++ tokens , nil }
188186 end
189187 end
190188 ## DONEPROC
191189 defp decode_token ( << @ tds_token_doneproc , status :: int16 , cur_cmd :: binary ( 2 ) , row_count :: little - size ( 8 ) - unit ( 8 ) , _tail :: binary >> , tokens ) do
192- case tokens do
193- [ done: done ] ->
194- cond do
195- row_count > done . rows -> { [ done: % { status: status , cmd: cur_cmd , rows: row_count } ] ++ tokens , nil }
196- true -> { tokens , nil }
197- end
190+ case Keyword . get ( tokens , :done ) do
191+ nil ->
192+ { Keyword . put ( tokens , :done , % { status: status , cmd: cur_cmd , rows: row_count } ) , nil }
193+ % { rows: rows } when row_count > rows ->
194+ { Keyword . put ( tokens , :done , % { status: status , cmd: cur_cmd , rows: row_count } ) , nil }
195+ _ ->
198196 { tokens , nil }
199- _ -> { [ done: % { status: status , cmd: cur_cmd , rows: row_count } ] ++ tokens , nil }
200197 end
201198 end
202199 ## DONEINPROC
203200 defp decode_token ( << @ tds_token_doneinproc , status :: int16 , cur_cmd :: binary ( 2 ) , row_count :: little - size ( 8 ) - unit ( 8 ) , _something :: binary - size ( 5 ) , tail :: binary >> , tokens ) do
204- case tokens do
205- [ done: done ] ->
206- cond do
207- row_count > done . rows -> { [ done: % { status: status , cmd: cur_cmd , rows: row_count } ] ++ tokens , nil }
208- true -> { tokens , tail }
209- end
201+ case Keyword . get ( tokens , :done ) do
202+ nil ->
203+ { Keyword . put ( tokens , :done , % { status: status , cmd: cur_cmd , rows: row_count } ) , tail }
204+ % { rows: rows } when row_count > rows ->
205+ { Keyword . put ( tokens , :done , % { status: status , cmd: cur_cmd , rows: row_count } ) , nil }
206+ _ ->
210207 { tokens , nil }
211- _ -> { [ done: % { status: status , cmd: cur_cmd , rows: row_count } ] ++ tokens , tail }
212208 end
209+
210+ # case tokens do
211+ # [done: done] ->
212+ # cond do
213+ # row_count > done.rows -> {[done: %{status: status, cmd: cur_cmd, rows: row_count}] ++ tokens, nil}
214+ # true -> {tokens, tail}
215+ # end
216+ # {tokens, nil}
217+ # _ -> {[done: %{status: status, cmd: cur_cmd, rows: row_count}] ++ tokens, tail}
218+ # end
213219 end
214220
215221 defp decode_column_order ( << tail :: binary >> , n , columns ) when n == 0 do
0 commit comments