Skip to content

Commit 916f973

Browse files
greg-rychlewskiGreg Rychlewski
and
Greg Rychlewski
authored
Add connection tests for selecting binary uuid (#122)
Co-authored-by: Greg Rychlewski <[email protected]>
1 parent 778fdd4 commit 916f973

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
defmodule Ecto.Adapters.SQLite3.Connection.BinaryUUIDTest do
2+
use ExUnit.Case, async: false
3+
4+
import Ecto.Query
5+
import Ecto.Adapters.SQLite3.TestHelpers
6+
7+
alias EctoSQLite3.Schemas.Schema
8+
9+
setup_all do
10+
Application.put_env(:ecto_sqlite3, :uuid_type, :binary)
11+
Application.put_env(:ecto_sqlite3, :binary_id_type, :binary)
12+
13+
on_exit(fn ->
14+
Application.put_env(:ecto_sqlite3, :uuid_type, :string)
15+
Application.put_env(:ecto_sqlite3, :binary_id_type, :string)
16+
end)
17+
end
18+
19+
describe "select" do
20+
test "casting uuid" do
21+
query =
22+
Schema
23+
|> select([], type(^"601d74e4-a8d3-4b6e-8365-eddb4c893327", Ecto.UUID))
24+
|> plan()
25+
26+
assert ~s{SELECT ? FROM "schema" AS s0} == all(query)
27+
end
28+
29+
test "casting binary_ids" do
30+
query =
31+
Schema
32+
|> select([], type(^"601d74e4-a8d3-4b6e-8365-eddb4c893327", :binary_id))
33+
|> plan()
34+
35+
assert ~s{SELECT ? FROM "schema" AS s0} == all(query)
36+
end
37+
end
38+
end

0 commit comments

Comments
 (0)