Skip to content

Commit

Permalink
mix format
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexR2D2 committed Jun 5, 2024
1 parent e29b643 commit e29260c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ defmodule Duckdbex.MixProject do

defp nif_versions(opts) do
if String.contains?(opts.target, "windows") or
String.contains?(opts.target, "darwin") do
String.contains?(opts.target, "darwin") do
["2.16"]
else
["2.15"]
Expand Down
5 changes: 4 additions & 1 deletion test/duckdbex_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ defmodule DuckdbexTest do
test "columns/1" do
assert {:ok, db} = Duckdbex.open()
assert {:ok, conn} = Duckdbex.connection(db)
assert {:ok, result} = Duckdbex.query(conn, "SELECT 1 as 'one_column_name', 2 WHERE 1 = $1;", [1])

assert {:ok, result} =
Duckdbex.query(conn, "SELECT 1 as 'one_column_name', 2 WHERE 1 = $1;", [1])

assert ["one_column_name", "2"] = Duckdbex.columns(result)
end

Expand Down
14 changes: 12 additions & 2 deletions test/nif/csv_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@ defmodule Duckdbex.Nif.CSVTest do
end

test "read csv using user defined options", %{conn: conn} do
assert {:ok, res} = Duckdbex.NIF.query(conn, "SELECT * FROM read_csv('test/support/data.csv', header = false);")
assert {:ok, res} =
Duckdbex.NIF.query(
conn,
"SELECT * FROM read_csv('test/support/data.csv', header = false);"
)

assert [["c1", "c2", "c3"], ["1", "2", "3"], ["a", "b", "c"]] = Duckdbex.NIF.fetch_all(res)

assert {:ok, res} = Duckdbex.NIF.query(conn, "SELECT * FROM read_csv('test/support/data.csv', header = true);")
assert {:ok, res} =
Duckdbex.NIF.query(
conn,
"SELECT * FROM read_csv('test/support/data.csv', header = true);"
)

assert [["1", "2", "3"], ["a", "b", "c"]] = Duckdbex.NIF.fetch_all(res)
end

Expand Down
4 changes: 3 additions & 1 deletion test/nif/open_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ defmodule Duckdbex.Nif.OpenTest do
end

test "directory of DB file not found" do
assert {:error, <<"{\"exception_type\":\"IO\",\"exception_message\":\"Cannot open file", _rest::binary>>} =
assert {:error,
<<"{\"exception_type\":\"IO\",\"exception_message\":\"Cannot open file",
_rest::binary>>} =
Duckdbex.NIF.open("/root/user/asf#fdscgwgj4/db.duckdb", nil)
end
end
2 changes: 1 addition & 1 deletion test/nif/types_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ defmodule Duckdbex.Nif.QueryTest do
assert [[%{"1" => 1, "5" => 2}]] = NIF.fetch_all(r)

assert {:error, "Conversion Error:" <> _details} =
NIF.query(conn, "SELECT map([1, 2, 3], [1, 'a', 2.4::DECIMAL(3, 2)]);")
NIF.query(conn, "SELECT map([1, 2, 3], [1, 'a', 2.4::DECIMAL(3, 2)]);")

assert {:ok, r} =
NIF.query(conn, "select map([['a', 'b'], ['c', 'd']], [[1.1, 2.2], [3.3, 4.4]]);")
Expand Down

0 comments on commit e29260c

Please sign in to comment.