Skip to content

Commit 99cec9a

Browse files
author
spicychickensauce
committed
Cast to appropriate type in values expression
1 parent b86ecbb commit 99cec9a

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

lib/ecto/adapters/sqlite3/connection.ex

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,18 +1573,11 @@ defmodule Ecto.Adapters.SQLite3.Connection do
15731573
end
15741574

15751575
defp values_expr(types, idx) do
1576-
intersperse_reduce(types, ?,, idx, fn {_field, _type}, idx ->
1577-
# TODO: cast?
1578-
# {[?$, Integer.to_string(idx), ?:, ?: | tagged_to_db(type)], idx + 1}
1579-
{[?$, Integer.to_string(idx)], idx + 1}
1576+
intersperse_reduce(types, ?,, idx, fn {_field, type}, idx ->
1577+
{[?$, Integer.to_string(idx), ?:, ?: | column_type(type, nil)], idx + 1}
15801578
end)
15811579
end
15821580

1583-
# defp tagged_to_db(:id), do: "bigint"
1584-
# defp tagged_to_db(:integer), do: "bigint"
1585-
# defp tagged_to_db({:array, type}), do: [tagged_to_db(type), ?[, ?]]
1586-
# defp tagged_to_db(type), do: ecto_to_db(type)
1587-
15881581
def interval(_, "microsecond", _sources) do
15891582
raise ArgumentError,
15901583
"SQLite does not support microsecond precision in datetime intervals"

test/ecto/adapters/sqlite3/connection/join_test.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ defmodule Ecto.Adapters.SQLite3.Connection.JoinTest do
158158
col_names = Map.keys(types) |> Enum.join(", ")
159159

160160
assert ~s{SELECT s0."id", v1."x" FROM "schema" AS s0 } <>
161-
~s{INNER JOIN (WITH temp_78027(#{col_names}) AS (VALUES ($1,$2),($3,$4)) SELECT * FROM temp_78027) AS v1 } <>
161+
~s{INNER JOIN (WITH temp_78027(#{col_names}) AS (VALUES ($1::INTEGER,$2::INTEGER),($3::INTEGER,$4::INTEGER)) } <>
162+
~s{SELECT * FROM temp_78027) AS v1 } <>
162163
~s{ON (v1."x" = s0."x") AND (v1."y" = s0."y")} ==
163164
all(query)
164165
end

0 commit comments

Comments
 (0)