Skip to content

update Ecto to v3.13 #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 19, 2025
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is loosely based on [Keep a Changelog][keepachangelog], and this
project adheres to [Semantic Versioning][semver].

## Unreleased
- added: Ecto [`identifier/1`](https://hexdocs.pm/ecto/Ecto.Query.API.html#identifier/1) support
- changed: Bump (and restrict) Ecto to `3.13.0`

## v0.19.0
- changed: Configurable encoding for `:map` and `:array`, allowing usage of SQLite's JSONB storage format.
Expand Down
2 changes: 1 addition & 1 deletion lib/ecto/adapters/sqlite3/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ defmodule Ecto.Adapters.SQLite3.Connection do
raise ArgumentError, "SQLite3 adapter does not support values lists"
end

defp expr({:literal, _, [literal]}, _sources, _query) do
defp expr({:identifier, _, [literal]}, _sources, _query) do
quote_name(literal)
end

Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ defmodule EctoSQLite3.MixProject do
defp deps do
[
{:decimal, "~> 1.6 or ~> 2.0"},
{:ecto_sql, "~> 3.12"},
{:ecto, "~> 3.12"},
{:ecto_sql, "~> 3.13.0"},
{:ecto, "~> 3.13.0"},
{:exqlite, "~> 0.22"},
{:ex_doc, "~> 0.27", only: [:dev], runtime: false},
{:jason, ">= 0.0.0", only: [:dev, :test, :docs]},
Expand Down
4 changes: 2 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"decimal": {:hex, :decimal, "2.3.0", "3ad6255aa77b4a3c4f818171b12d237500e63525c2fd056699967a3e7ea20f62", [:mix], [], "hexpm", "a4d66355cb29cb47c3cf30e71329e58361cfcb37c34235ef3bf1d7bf3773aeac"},
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
"earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"},
"ecto": {:hex, :ecto, "3.12.5", "4a312960ce612e17337e7cefcf9be45b95a3be6b36b6f94dfb3d8c361d631866", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6eb18e80bef8bb57e17f5a7f068a1719fbda384d40fc37acb8eb8aeca493b6ea"},
"ecto_sql": {:hex, :ecto_sql, "3.12.1", "c0d0d60e85d9ff4631f12bafa454bc392ce8b9ec83531a412c12a0d415a3a4d0", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.12", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.7", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.19 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "aff5b958a899762c5f09028c847569f7dfb9cc9d63bdb8133bff8a5546de6bf5"},
"ecto": {:hex, :ecto, "3.13.1", "ebb11c2f0307ff62e8aaba57def59ad920a3cbd89d002b1118944cbf598c13c7", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d9ea5075a6f3af9cd2cdbabe8a0759eb73b485e981fd7c03014f79479ac85340"},
"ecto_sql": {:hex, :ecto_sql, "3.13.0", "a732428f38ce86612a2c34a1ea5d0a9642a5a71f044052007fd2f2e815707990", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.13.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.7", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.19 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "5ce13085122a0871d93ea9ba1a886447d89c07f3b563e19e0b3dcdf201ed9fe9"},
"elixir_make": {:hex, :elixir_make, "0.9.0", "6484b3cd8c0cee58f09f05ecaf1a140a8c97670671a6a0e7ab4dc326c3109726", [:mix], [], "hexpm", "db23d4fd8b757462ad02f8aa73431a426fe6671c80b200d9710caf3d1dd0ffdb"},
"ex_doc": {:hex, :ex_doc, "0.37.3", "f7816881a443cd77872b7d6118e8a55f547f49903aef8747dbcb345a75b462f9", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "e6aebca7156e7c29b5da4daa17f6361205b2ae5f26e5c7d8ca0d3f7e18972233"},
"exqlite": {:hex, :exqlite, "0.30.0", "92cd991fc7fcdf688718452bca5012ffa9015d333845d7661ee00c8256e80423", [:make, :mix], [{:cc_precompiler, "~> 0.1", [hex: :cc_precompiler, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.8", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "3ed5800d1ccafc220d4a2e0bc7cf2c0e2f93456f03f73856158b474e010c792c"},
Expand Down
9 changes: 9 additions & 0 deletions test/ecto/adapters/sqlite3/connection/select_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,21 @@
test "collating with literal" do
query =
Schema
|> select([r], fragment("? COLLATE ?", r.x, literal(^"es_ES")))

Check warning on line 163 in test/ecto/adapters/sqlite3/connection/select_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.17, OTP 25, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 163 in test/ecto/adapters/sqlite3/connection/select_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.18, OTP 27, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 163 in test/ecto/adapters/sqlite3/connection/select_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.16, OTP 25, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 163 in test/ecto/adapters/sqlite3/connection/select_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.15, OTP 26, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 163 in test/ecto/adapters/sqlite3/connection/select_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.15, OTP 25, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 163 in test/ecto/adapters/sqlite3/connection/select_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.18, OTP 26, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 163 in test/ecto/adapters/sqlite3/connection/select_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.17, OTP 27, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 163 in test/ecto/adapters/sqlite3/connection/select_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.18, OTP 25, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 163 in test/ecto/adapters/sqlite3/connection/select_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.17, OTP 26, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 163 in test/ecto/adapters/sqlite3/connection/select_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.16, OTP 26, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.
|> plan()

assert ~s{SELECT s0."x" COLLATE "es_ES" FROM "schema" AS s0} == all(query)
end

test "collating with identifier" do
query =
Schema
|> select([r], fragment("? COLLATE ?", r.x, identifier(^"es_ES")))
|> plan()

assert ~s{SELECT s0."x" COLLATE "es_ES" FROM "schema" AS s0} == all(query)
end

test "fragment with a column and value specified" do
value = 13

Expand Down Expand Up @@ -233,7 +242,7 @@
query =
"schema"
|> where(foo: <<0, ?a, ?b, ?c>>)
|> select([], true)

Check warning on line 245 in test/ecto/adapters/sqlite3/connection/select_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.15, OTP 26, OS ubuntu-latest

this check/guard will always yield the same result

Check warning on line 245 in test/ecto/adapters/sqlite3/connection/select_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.15, OTP 25, OS ubuntu-latest

this check/guard will always yield the same result
|> plan()

assert ~s{SELECT 1 FROM "schema" AS s0 WHERE (s0."foo" = x'00616263')} ==
Expand Down
10 changes: 10 additions & 0 deletions test/ecto/integration/crud_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,22 @@
account1 = TestRepo.insert!(%Account{name: "Main"})

name = "name"
query = from(a in Account, where: fragment("? = ?", literal(^name), "Main"))

Check warning on line 279 in test/ecto/integration/crud_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.17, OTP 25, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 279 in test/ecto/integration/crud_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.18, OTP 27, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 279 in test/ecto/integration/crud_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.16, OTP 25, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 279 in test/ecto/integration/crud_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.15, OTP 26, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 279 in test/ecto/integration/crud_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.15, OTP 25, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 279 in test/ecto/integration/crud_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.18, OTP 26, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 279 in test/ecto/integration/crud_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.17, OTP 27, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 279 in test/ecto/integration/crud_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.18, OTP 25, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 279 in test/ecto/integration/crud_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.17, OTP 26, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

Check warning on line 279 in test/ecto/integration/crud_test.exs

View workflow job for this annotation

GitHub Actions / Test Elixir 1.16, OTP 26, OS ubuntu-latest

`literal/1` is deprecated. Please use `identifier/1` instead.

assert [account] = TestRepo.all(query)
assert account.id == account1.id
end

test "can handle fragment identifier" do
account1 = TestRepo.insert!(%Account{name: "Main"})

name = "name"
query = from(a in Account, where: fragment("? = ?", identifier(^name), "Main"))

assert [account] = TestRepo.all(query)
assert account.id == account1.id
end

test "can handle selected_as" do
TestRepo.insert!(%Account{name: "Main"})
TestRepo.insert!(%Account{name: "Main"})
Expand Down
Loading