Skip to content

Commit

Permalink
added type parser test
Browse files Browse the repository at this point in the history
  • Loading branch information
whossname committed Sep 14, 2019
1 parent 14f92cd commit 63ee5b5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions integration/mssql/type_parser.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
defmodule Ecto.Integration.TypeParserTest do
use Ecto.Integration.Case, async: Application.get_env(:ecto, :async_integration_tests, true)

alias Ecto.Integration.TestRepo
import Ecto.Query

alias Ecto.Integration.Post
alias Ecto.Integration.Comment
alias Ecto.Integration.Permalink
alias Ecto.Integration.User
alias Ecto.Integration.PostUserCompositePk

test "joins with column alias" do
_p = TestRepo.insert!(%Post{title: "1"})
p2 = TestRepo.insert!(%Post{title: "2"})
c1 = TestRepo.insert!(%Permalink{url: "1", post_id: p2.id})

query =
from(p in Post,
join: c in assoc(p, :permalink),
on: c.id == ^c1.id,
select: %{post_id: p.id, link_id: c.id}
)

expected = %{link_id: c1.id, post_id: p2.id}
assert [expected] = TestRepo.all(query)
end
end

0 comments on commit 63ee5b5

Please sign in to comment.