Skip to content

Commit 14ee96b

Browse files
committed
return literal/1 tests
1 parent f70c79c commit 14ee96b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ defmodule Ecto.Adapters.SQLite3.Connection.SelectTest do
157157
assert ~s{SELECT downcase(s0."x") FROM "schema" AS s0} == all(query)
158158
end
159159

160+
test "collating with literal" do
161+
query =
162+
Schema
163+
|> select([r], fragment("? COLLATE ?", r.x, literal(^"es_ES")))
164+
|> plan()
165+
166+
assert ~s{SELECT s0."x" COLLATE "es_ES" FROM "schema" AS s0} == all(query)
167+
end
168+
160169
test "collating with identifier" do
161170
query =
162171
Schema

test/ecto/integration/crud_test.exs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,16 @@ defmodule Ecto.Integration.CrudTest do
272272
assert [_] = TestRepo.all(from(a in Account, as: :user, where: exists(subquery)))
273273
end
274274

275+
test "can handle fragment literal" do
276+
account1 = TestRepo.insert!(%Account{name: "Main"})
277+
278+
name = "name"
279+
query = from(a in Account, where: fragment("? = ?", literal(^name), "Main"))
280+
281+
assert [account] = TestRepo.all(query)
282+
assert account.id == account1.id
283+
end
284+
275285
test "can handle fragment identifier" do
276286
account1 = TestRepo.insert!(%Account{name: "Main"})
277287

0 commit comments

Comments
 (0)