Skip to content

Commit

Permalink
chore: remove a bit of hard coding
Browse files Browse the repository at this point in the history
  • Loading branch information
lejoko committed May 16, 2024
1 parent f972c0e commit a7446b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ if Mix.env() == :test do
AshMysql.Test.Domain
]

config :logger, level: :debug
config :logger, level: :warning
end
5 changes: 3 additions & 2 deletions lib/data_layer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ defmodule AshMysql.DataLayer do
reload_key = Ash.Resource.Info.primary_key(resource) |> Enum.at(0)
keys_to_reload = entries |> Enum.map(&Map.get(&1, reload_key))

unordered = Ecto.Query.from(s in source, where: s.id in ^keys_to_reload) |> repo.all()
unordered = Ecto.Query.from(s in source, where: field(s, ^reload_key) in ^keys_to_reload) |> repo.all()
indexed = unordered |> Enum.group_by(&Map.get(&1, reload_key))

ordered =
Expand Down Expand Up @@ -973,7 +973,8 @@ defmodule AshMysql.DataLayer do
# name
# end)

names = [:id]
names = Ash.Resource.Info.primary_key(resource)

message = find_constraint_message(resource, names)

{:error,
Expand Down

0 comments on commit a7446b1

Please sign in to comment.