Skip to content

Commit

Permalink
fix: revert code changes breaking ecto record loading (#447)
Browse files Browse the repository at this point in the history
* fix: revert code changes breaking ecto record loading

* remove duplicate spec line
  • Loading branch information
btkostner authored May 21, 2024
1 parent c9ebb47 commit b796311
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/ex_machina/ecto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,11 @@ defmodule ExMachina.Ecto do
association = struct.__schema__(:association, association_name)

with %{__struct__: Ecto.Association.BelongsTo} <- association,
%{__meta__: %{__struct__: Ecto.Schema.Metadata, state: :loaded}} = belongs_to <-
Map.get(record, association_name) do
belongs_to <- Map.get(record, association_name),
%{__meta__: %{__struct__: Ecto.Schema.Metadata, state: :loaded}} <- belongs_to do
set_belongs_to_primary_key(record, belongs_to, association)
else
_ -> record
end
end)
end
Expand Down
3 changes: 1 addition & 2 deletions lib/ex_machina/sequence.ex
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,13 @@ defmodule ExMachina.Sequence do
ExMachina.Sequence.next("joe") # "joe0"
"""

@spec reset(list()) :: :ok
@spec reset(any()) :: :ok
def reset(sequence_names) when is_list(sequence_names) do
Agent.update(__MODULE__, fn sequences ->
Enum.reduce(sequence_names, sequences, &Map.put(&2, &1, 0))
end)
end

@spec reset(any()) :: :ok
def reset(sequence_name) do
Agent.update(__MODULE__, fn sequences ->
Map.put(sequences, sequence_name, 0)
Expand Down

0 comments on commit b796311

Please sign in to comment.