@@ -893,6 +893,18 @@ defmodule Ecto.Adapters.MyXQLTest do
893893 "SELECT s0.`id`, s1.`id` FROM `schema` AS s0 LEFT OUTER JOIN `schema2` AS s1 ON TRUE"
894894 end
895895
896+ test "lateral join with fragment" do
897+ query = Schema
898+ |> join ( :inner_lateral , [ p ] , q in fragment ( "SELECT * FROM schema2 AS s2 WHERE s2.id = ? AND s2.field = ?" , p . x , ^ 10 ) )
899+ |> select ( [ p , q ] , { p . id , q . z } )
900+ |> where ( [ p ] , p . id > 0 and p . id < ^ 100 )
901+ |> plan ( )
902+ assert all ( query ) ==
903+ ~s{ SELECT s0.`id`, f1.`z` FROM `schema` AS s0 INNER JOIN LATERAL } <>
904+ ~s{ (SELECT * FROM schema2 AS s2 WHERE s2.id = s0.`x` AND s2.field = ?) AS f1 ON TRUE } <>
905+ ~s{ WHERE ((s0.`id` > 0) AND (s0.`id` < ?))}
906+ end
907+
896908 test "cross join" do
897909 query = from ( p in Schema , cross_join: c in Schema2 , select: { p . id , c . id } ) |> plan ( )
898910 assert all ( query ) ==
@@ -1406,16 +1418,6 @@ defmodule Ecto.Adapters.MyXQLTest do
14061418
14071419 # Unsupported types and clauses
14081420
1409- test "lateral join with fragment" do
1410- assert_raise Ecto.QueryError , ~r" join `:inner_lateral` not supported by MySQL" , fn ->
1411- Schema
1412- |> join ( :inner_lateral , [ p ] , q in fragment ( "SELECT * FROM schema2 AS s2 WHERE s2.id = ? AND s2.field = ?" , p . x , ^ 10 ) )
1413- |> select ( [ p , q ] , { p . id , q . z } )
1414- |> plan ( )
1415- |> all
1416- end
1417- end
1418-
14191421 test "arrays" do
14201422 assert_raise Ecto.QueryError , ~r" Array type is not supported by MySQL" , fn ->
14211423 query = Schema |> select ( [ ] , fragment ( "?" , [ 1 , 2 , 3 ] ) ) |> plan ( )
0 commit comments