11defmodule Ecto.Adapters.SQLite3.DataTypeTest do
2- use ExUnit.Case , async: true
2+ use ExUnit.Case , async: false
33
44 alias Ecto.Adapters.SQLite3.DataType
55
6+ setup do
7+ Application . put_env ( :ecto_sqlite3 , :binary_id_type , :string )
8+ Application . put_env ( :ecto_sqlite3 , :uuid_type , :string )
9+
10+ on_exit ( fn ->
11+ Application . put_env ( :ecto_sqlite3 , :binary_id_type , :string )
12+ Application . put_env ( :ecto_sqlite3 , :uuid_type , :string )
13+ end )
14+ end
15+
616 describe ".column_type/2" do
717 test ":id is INTEGER" do
818 assert DataType . column_type ( :id , nil ) == "INTEGER"
@@ -16,16 +26,24 @@ defmodule Ecto.Adapters.SQLite3.DataTypeTest do
1626 assert DataType . column_type ( :bigserial , nil ) == "INTEGER"
1727 end
1828
19- test ":binary_id is TEXT" do
20- assert DataType . column_type ( :binary_id , nil ) == "TEXT"
29+ test ":binary_id is TEXT_UUID OR UUID" do
30+ assert DataType . column_type ( :binary_id , nil ) == "TEXT_UUID"
31+
32+ Application . put_env ( :ecto_sqlite3 , :binary_id_type , :binary )
33+
34+ assert DataType . column_type ( :binary_id , nil ) == "UUID"
2135 end
2236
2337 test ":string is TEXT" do
2438 assert DataType . column_type ( :string , nil ) == "TEXT"
2539 end
2640
27- test ":uuid is TEXT" do
28- assert DataType . column_type ( :uuid , nil ) == "TEXT"
41+ test ":uuid is TEXT_UUID or UUID" do
42+ assert DataType . column_type ( :uuid , nil ) == "TEXT_UUID"
43+
44+ Application . put_env ( :ecto_sqlite3 , :uuid_type , :binary )
45+
46+ assert DataType . column_type ( :uuid , nil ) == "UUID"
2947 end
3048
3149 test ":map is JSON" do
0 commit comments