Skip to content

Commit

Permalink
refactor to map_join
Browse files Browse the repository at this point in the history
  • Loading branch information
bradhanks committed Jan 8, 2024
1 parent da2b3b5 commit ab76d6f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/ecto/migration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -942,10 +942,15 @@ defmodule Ecto.Migration do
defp default_index_name(index) do
[index.table, index.columns, "index"]
|> List.flatten()
|> Enum.map(&to_string(&1))
|> Enum.map(&String.replace(&1, ~r"[^\w_]", "_"))
|> Enum.map(&String.replace_trailing(&1, "_", ""))
|> Enum.join("_")
|> Enum.map_join(
"_",
fn item ->
item
|> to_string()
|> String.replace(~r"[^\w]", "_")
|> String.replace_trailing("_", "")
end
)
|> String.to_atom()
end

Expand Down

0 comments on commit ab76d6f

Please sign in to comment.