Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion lib/ecto/adapters/sqlite3/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,24 @@ defmodule Ecto.Adapters.SQLite3.Connection do
'?'
end

# workaround for the fact that SQLite3 as of 3.35.4 does not support specifying table
# in the returning clause. when a later release adds the ability, this code can be deleted
def expr(
{{:., _, [{:parent_as, _, [{:&, _, [_idx]}]}, field]}, _, []},
_sources,
%{returning: true}
)
when is_atom(field) do
quote_name(field)
end

# workaround for the fact that SQLite3 as of 3.35.4 does not support specifying table
# in the returning clause. when a later release adds the ability, this code can be deleted
def expr({{:., _, [{:&, _, [_idx]}, field]}, _, []}, _sources, %{returning: true})
when is_atom(field) do
quote_name(field)
end

def expr(
{{:., _, [{:parent_as, _, [{:&, _, [idx]}]}, field]}, _, []},
_sources,
Expand Down Expand Up @@ -1609,7 +1627,7 @@ defmodule Ecto.Adapters.SQLite3.Connection do

defp returning(%{select: %{fields: fields}} = query, sources) do
[
" RETURNING " | select_fields(fields, sources, query)
" RETURNING " | select_fields(fields, sources, Map.put(query, :returning, true))
]
end

Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"ecto_sql": {:hex, :ecto_sql, "3.6.0", "5cb277b086618a644f2c5450316202a885716bb7726b9f13b74cb0708bea3a8f", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.6.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b3486d6e29ee4a0e7a381390c9c289bfbbaf5dc1971e269c579799d2300e5bd5"},
"elixir_make": {:hex, :elixir_make, "0.6.2", "7dffacd77dec4c37b39af867cedaabb0b59f6a871f89722c25b28fcd4bd70530", [:mix], [], "hexpm", "03e49eadda22526a7e5279d53321d1cced6552f344ba4e03e619063de75348d9"},
"ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
"exqlite": {:hex, :exqlite, "0.5.6", "37e947c5aba201effa3a21dbb8c369f5d0faf97e98a305d8a6797bb7498ef9f0", [:make, :mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "0743df317db1e2edd8346991158aaf07441d29c303badee5c6ebcf9a6ab97009"},
"exqlite": {:hex, :exqlite, "0.5.8", "b1942f9f51b27608917ec2f035e69f7ff6d846eccff5157e27c90c14a5d1a168", [:make, :mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "5bed331bf406c27c7dae42040b835f1371018595a9dc218f9b92927e8a7c47c5"},
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
Expand Down
10 changes: 5 additions & 5 deletions test/ecto/adapters/sqlite3/connection_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
UPDATE posts AS p0 \
SET title = 'bar' \
WHERE (p0.title = ?) \
RETURNING p0.content\
RETURNING content\
"""
end

Expand Down Expand Up @@ -1350,7 +1350,7 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
"""
UPDATE posts AS p0 \
SET title = 'foo' \
RETURNING p0.id, p0.title, p0.content\
RETURNING id, title, content\
"""

query =
Expand All @@ -1364,7 +1364,7 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
UPDATE schema AS s0 \
SET x = ? \
WHERE (s0.x = ?) \
RETURNING s0.x = ?\
RETURNING x = ?\
"""
end

Expand All @@ -1391,7 +1391,7 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
assert delete_all(query) ==
"""
DELETE FROM schema AS s0 \
WHERE (s0.x = 123) RETURNING s0.x\
WHERE (s0.x = 123) RETURNING x\
"""
end

Expand All @@ -1401,7 +1401,7 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
assert delete_all(query) ==
"""
DELETE FROM posts AS p0 \
RETURNING p0.id, p0.title, p0.content\
RETURNING id, title, content\
"""
end

Expand Down