Skip to content

Commit a407738

Browse files
committed
ping fix. It should return :disconnect if response is not :ok
1 parent 8cdbccc commit a407738

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

lib/tds/protocol.ex

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

61+
@spec ping(any) :: {:ok, any} | {:disconnect, Exception.t, any}
6162
def ping(state) do
6263
case send_query(~s{SELECT 'pong' as [msg]}, state) do
63-
{:ok, _, s} -> {:ok, s}
64+
{:ok, _, s} -> {:ok, s}
6465
{:error, err, s} -> {:disconnect, err, s}
6566
end
6667
end
@@ -311,7 +312,7 @@ defmodule Tds.Protocol do
311312
case msg_send(msg, s) do
312313
:ok ->
313314
{:noreply, %{s | state: :prelogin}}
314-
{:error, reason} ->
315+
{:error, reason, s} ->
315316
error(%Tds.Error{message: "tcp send: #{reason}"}, s)
316317
end
317318
end
@@ -538,8 +539,8 @@ defmodule Tds.Protocol do
538539
mod.send(sock, pak)
539540
end)
540541
case msg_recv(<<>>, s) do
541-
{:disconnect, _ , ex} ->
542-
{:error, ex}
542+
{:disconnect, _ex , _s}=res ->
543+
res
543544
buffer ->
544545
new_data(buffer, %{s | state: :executing, pak_header: ""})
545546
end
@@ -597,8 +598,8 @@ defmodule Tds.Protocol do
597598
end)
598599

599600
case msg_recv(<<>>, s) do
600-
{:disconnect, _ , ex} ->
601-
{:error, ex}
601+
{:disconnect, ex , s} ->
602+
{:error, ex, s}
602603
buffer ->
603604
new_data(buffer, %{s | state: :login})
604605
end

test/tds_issues.exs renamed to test/tds_issues_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ defmodule TdsIssuesTest do
1212
{:ok, [pid: pid]}
1313
end
1414

15+
@tag :manual
1516
test "issue 33: Sending Float with more than 9 characters should not fail", context do
1617
query("DROP TABLE hades_sealed_cfdis", [])
1718
query(

test/test_helper.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ Application.get_env(:tds, :opts)
3939
|> Tds.TestHelper.sqlcmd("IF NOT EXISTS(SELECT * FROM sys.databases where name = 'test') BEGIN CREATE DATABASE [test]; END;")
4040

4141
ExUnit.start()
42+
ExUnit.configure exclude: [:manual]

0 commit comments

Comments
 (0)