From 63ee5b597d5af02aebe9238251b03ceb7a5f71fa Mon Sep 17 00:00:00 2001 From: whossname Date: Sat, 14 Sep 2019 13:46:48 +0800 Subject: [PATCH] added type parser test --- integration/mssql/type_parser.exs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 integration/mssql/type_parser.exs diff --git a/integration/mssql/type_parser.exs b/integration/mssql/type_parser.exs new file mode 100644 index 0000000..ce13c98 --- /dev/null +++ b/integration/mssql/type_parser.exs @@ -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