Skip to content

Commit

Permalink
Remove redundant validate_attr case. (#5965)
Browse files Browse the repository at this point in the history
- After change from this PR (https://github.com/phoenixframework/phoenix/pull/4601/files#diff-4307581434ae66da4750cde438c2b192c4a11c8b71ba32dbf78aea36daa0ee3eR368), `:enum` valid case becomes redundant. Next line has general check that includes valid enum case.
- Also removed redundant passing throw for `:datetime` case. Instead, return already prepared result right away.
  • Loading branch information
ShPakvel authored Nov 9, 2024
1 parent 6c4ef6e commit 13e9895
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/mix/phoenix/schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ defmodule Mix.Phoenix.Schema do
mix phx.gen.schema Comment comments body:text status:enum:published:unpublished
"""

defp validate_attr!({name, :datetime}), do: validate_attr!({name, :naive_datetime})
defp validate_attr!({name, :datetime}), do: {name, :naive_datetime}

defp validate_attr!({name, :array}) do
Mix.raise("""
Expand All @@ -438,7 +438,6 @@ defmodule Mix.Phoenix.Schema do

defp validate_attr!({_name, :enum}), do: Mix.raise(@enum_missing_value_error)
defp validate_attr!({_name, type} = attr) when type in @valid_types, do: attr
defp validate_attr!({_name, {:enum, _vals}} = attr), do: attr
defp validate_attr!({_name, {type, _}} = attr) when type in @valid_types, do: attr

defp validate_attr!({_, type}) do
Expand Down

0 comments on commit 13e9895

Please sign in to comment.