Skip to content
Open
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- **Unsupported Query Expressions Raise** - An expression the adapter cannot translate now raises `Ecto.QueryError` ("unsupported expression ...") instead of being rendered as a `?` placeholder, which bound the wrong parameter in its place and silently changed the query.

## [0.9.1] - 2026-05-07

### Fixed
Expand Down
9 changes: 6 additions & 3 deletions lib/ecto/adapters/libsql/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1384,9 +1384,12 @@ defmodule Ecto.Adapters.LibSql.Connection do
defp expr(false, _sources, _query), do: "0"
defp expr(nil, _sources, _query), do: "NULL"

# Default fallback for unsupported expressions
defp expr(_expr, _sources, _query) do
"?"
# Unsupported expressions raise: rendering them as a placeholder would bind
# the next parameter in their place and silently change the query.
defp expr(expr, _sources, query) do
raise Ecto.QueryError,
query: query,
message: "unsupported expression #{inspect(expr)}"
end

defp combination(%{combinations: []}, _as_prefix), do: []
Expand Down
10 changes: 10 additions & 0 deletions test/in_expression_comprehensive_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -507,4 +507,14 @@ defmodule EctoLibSql.InExpressionComprehensiveTest do
assert "item3" in result
end
end

describe "unsupported expressions" do
test "raise instead of being rendered as a \"?\" placeholder" do
query = from(t in "test_items", where: ilike(t.name, "job%"), select: t.name)

assert_raise Ecto.QueryError, ~r/unsupported expression/, fn ->
Ecto.Adapters.SQL.to_sql(:all, TestRepo, query)
end
end
end
end