Skip to content

Commit 70e3b07

Browse files
Update selected_as/1 exclusions for pg and tds (#433)
1 parent c8686ae commit 70e3b07

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

integration_test/pg/test_helper.exs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,14 @@ version =
9696
_other -> version
9797
end
9898

99+
excludes = [:selected_as_with_having, :selected_as_with_order_by_expression]
99100
excludes_above_9_5 = [:without_conflict_target]
100101
excludes_below_9_6 = [:add_column_if_not_exists, :no_error_on_conditional_column_migration]
101102

102103
if Version.match?(version, "< 9.6.0") do
103-
ExUnit.configure(exclude: excludes_above_9_5 ++ excludes_below_9_6)
104+
ExUnit.configure(exclude: excludes ++ excludes_above_9_5 ++ excludes_below_9_6)
104105
else
105-
ExUnit.configure(exclude: excludes_above_9_5)
106+
ExUnit.configure(exclude: excludes ++ excludes_above_9_5)
106107
end
107108

108109
:ok = Ecto.Migrator.up(TestRepo, 0, Ecto.Integration.Migration, log: false)

integration_test/tds/test_helper.exs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ ExUnit.start(
5050
# MSSQL fails the regex matching because it uses square brackets outside of the parameter list
5151
:parameter_logging,
5252
# MSSQL can't reference aliased columns in GROUP BY
53-
:selected_as_with_group_by
53+
:selected_as_with_group_by,
54+
# MSSQL can't reference aliased columns in HAVING
55+
:selected_as_with_having,
56+
# MSSQL can't reference aliased columns in ORDER BY expressions
57+
:selected_as_with_order_by_expression
5458
]
5559
)
5660

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"decimal": {:hex, :decimal, "1.9.0", "83e8daf59631d632b171faabafb4a9f4242c514b0a06ba3df493951c08f64d07", [:mix], [], "hexpm", "b1f2343568eed6928f3e751cf2dffde95bfaa19dd95d09e8a9ea92ccfd6f7d85"},
77
"deep_merge": {:hex, :deep_merge, "0.2.0", "c1050fa2edf4848b9f556fba1b75afc66608a4219659e3311d9c9427b5b680b3", [:mix], [], "hexpm", "e3bf435a54ed27b0ba3a01eb117ae017988804e136edcbe8a6a14c310daa966e"},
88
"earmark_parser": {:hex, :earmark_parser, "1.4.25", "2024618731c55ebfcc5439d756852ec4e85978a39d0d58593763924d9a15916f", [:mix], [], "hexpm", "56749c5e1c59447f7b7a23ddb235e4b3defe276afc220a6227237f3efe83f51e"},
9-
"ecto": {:git, "https://github.com/elixir-ecto/ecto.git", "4f541892e738a4dfad66601e19db3567e3335c2c", []},
9+
"ecto": {:git, "https://github.com/elixir-ecto/ecto.git", "8d1fa601a91a77f5eeb502ad8787f82c80caab8c", []},
1010
"ex_doc": {:hex, :ex_doc, "0.28.4", "001a0ea6beac2f810f1abc3dbf4b123e9593eaa5f00dd13ded024eae7c523298", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "bf85d003dd34911d89c8ddb8bda1a958af3471a274a4c2150a9c01c78ac3f8ed"},
1111
"jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"},
1212
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},

test/ecto/adapters/myxql_test.exs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,17 @@ defmodule Ecto.Adapters.MyXQLTest do
557557
assert all(query) == ~s{SELECT s0.`x` AS integer FROM `schema` AS s0 ORDER BY integer DESC}
558558
end
559559

560+
test "having can reference the alias of a selected value with selected_as/1" do
561+
query =
562+
"schema"
563+
|> select([s], selected_as(s.x, :integer))
564+
|> group_by(selected_as(:integer))
565+
|> having(selected_as(:integer) > 0)
566+
|> plan()
567+
568+
assert all(query) == ~s{SELECT s0.`x` AS integer FROM `schema` AS s0 GROUP BY integer HAVING (integer > 0)}
569+
end
570+
560571
test "tagged type" do
561572
query = Schema |> select([], type(^"601d74e4-a8d3-4b6e-8365-eddb4c893327", Ecto.UUID)) |> plan()
562573
assert all(query) == ~s{SELECT CAST(? AS binary(16)) FROM `schema` AS s0}

0 commit comments

Comments
 (0)