Skip to content

Commit d2085d1

Browse files
committed
fixing order of rows in result
1 parent cdc6460 commit d2085d1

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/tds/protocol.ex

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ defmodule Tds.Protocol do
5858
mod.close(sock)
5959
end
6060

61-
def ping(s) do
62-
63-
{:ok, s}
61+
def ping(state) do
62+
case send_query(~s{SELECT 'pong' as [msg]}, state) do
63+
{:ok, s} -> {:ok, s}
64+
{:error, err, s} -> {:disconnect, err, s}
65+
end
6466
end
6567

6668
def checkout(%{sock: {_mod, sock}} = s) do
@@ -482,8 +484,9 @@ defmodule Tds.Protocol do
482484
columns
483485
end
484486
num_rows = done.rows;
485-
rows =
486-
if rows != nil, do: Enum.reverse(rows), else: rows
487+
# rows are correctly orrdered when they were parsed, so below is not needed anymore
488+
# rows =
489+
# if rows != nil, do: Enum.reverse(rows), else: rows
487490
rows = if num_rows == 0 && rows == nil, do: [], else: rows
488491

489492
result = %Tds.Result{columns: columns, rows: rows, num_rows: num_rows}

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule Tds.Mixfile do
33

44
def project do
55
[ app: :tds,
6-
version: "1.0.3",
6+
version: "1.0.4",
77
elixir: "~> 1.0",
88
deps: deps(),
99
test_coverage: [tool: ExCoveralls],

0 commit comments

Comments
 (0)