-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validate keys for references/2 #592
validate keys for references/2 #592
Conversation
lib/ecto/migration.ex
Outdated
:with, | ||
:match | ||
]) | ||
|
||
opts = Keyword.merge(foreign_key_repo_opts(), opts) | ||
reference = struct(%Reference{table: table}, opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could use struct!
here instead?
💚 💙 💜 💛 ❤️ |
I recently upgraded from v3.11.3 to v3.12.0 and tests started failing. Looks like this PR was the reason -- turns out one of our migrations had the kind of bug this PR was designed to fix. I think it's a good change, but dropping this needle in case others find themselves in the same haystack. ** (KeyError) key :mode not found in: %Ecto.Migration.Table{
name: "foo",
prefix: nil,
comment: nil,
primary_key: true,
engine: nil,
options: nil
}
(stdlib 5.2) :maps.update(:mode, :cascade, %Ecto.Migration.Table{name: "foo", prefix: nil, comment: nil, primary_key: true, engine: nil, options: nil})
(elixir 1.16.1) lib/kernel.ex:2442: anonymous fn/2 in Kernel.struct!/2
(elixir 1.16.1) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
iex:3: (file) |
edit: false alarm, see below comment 😓
add(:other_table_id, references(:other_table, on_delete: :delete_all), null: false)
|
@adamu Are you sure If you're sure, could you please provide a small script like this that creates the issue? Thank you |
Hi @greg-rychlewski, I have to apologise, it appears I was misreading the migration log 😳 It was along the lines of this:
Where I was then looking in the Apologies for the noise. |
Hi there, I recently had a bug where I accidentally used
instead of
This PR enforces that only supported keys are used.