Skip to content

Commit eeb9867

Browse files
author
Simon Thörnqvist
committed
tvp test
1 parent 4d804a7 commit eeb9867

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/tvp_test.exs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
defmodule TvpTest do
2+
import Tds.TestHelper
3+
require Logger
4+
use ExUnit.Case, async: true
5+
alias Tds.Parameter
6+
7+
@tag timeout: 50000
8+
9+
setup do
10+
opts = Application.fetch_env!(:tds, :opts)
11+
{:ok, pid} = Tds.start_link(opts)
12+
13+
{:ok, [pid: pid]}
14+
end
15+
16+
test "TVP in stored proc", context do
17+
assert :ok = query("BEGIN TRY DROP PROCEDURE __tvpTest DROP TYPE TvpTestType END TRY BEGIN CATCH END CATCH", [])
18+
assert :ok = query("""
19+
CREATE TYPE TvpTestType AS TABLE (
20+
d int
21+
);
22+
""", [])
23+
assert :ok = query("""
24+
CREATE PROCEDURE __tvpTest (@tvp TvpTestType readonly)
25+
AS BEGIN
26+
select * from @tvp
27+
END
28+
""", [])
29+
30+
params = [
31+
%Parameter{name: "@tvp", value: %{name: "TvpTestType", columns: [%Parameter{name: "d", type: :integer, value: nil}], rows: [[1]]}, type: :tvp}
32+
]
33+
34+
assert {:ok, res} = query("__tvpTest @tvp", params)
35+
end
36+
end

0 commit comments

Comments
 (0)