Fix structure_load/2 for MySQL 9.4+#685
Merged
wojtekmach merged 2 commits intomasterfrom Aug 13, 2025
Merged
Conversation
On MySQL 9.4+, `--execute "SOURCE {path}"` is no longer supported.
Member
Author
|
@yordis could you try |
josevalim
reviewed
Aug 13, 2025
lib/ecto/adapters/myxql.ex
Outdated
| case run_with_cmd("mysql", config, args) do | ||
| {_output, 0} -> {:ok, path} | ||
| {output, _} -> {:error, output} | ||
| with {:ok, contents} <- File.read(path) do |
Member
There was a problem hiding this comment.
Will downstream be able to handle {:error, atom()}?
Member
Author
There was a problem hiding this comment.
Good call, yes it handles it:
$ mix ecto.load
** (Mix) The structure for Dummy.Repo couldn't be loaded: :enoent
however previously it was a slightly better error message:
** (Mix) The structure for Dummy.Repo couldn't be loaded: ERROR at line 1: Failed to open file '/Users/wojtek/dummy/priv/repo/structure.sql', error: 2
I will do something like:
{:error, reason} ->
{:error, "could not read #{inspect(path)}: #{:file.format_error(reason)}"}so that we have:
** (Mix) The structure for Dummy.Repo couldn't be loaded: could not read "/Users/wojtek/dummy/priv/repo/structure.sql": no such file or directory
josevalim
approved these changes
Aug 13, 2025
yordis
approved these changes
Aug 13, 2025
Contributor
yordis
left a comment
There was a problem hiding this comment.
I ran the test locally, with mysql-client@9.4 and it is passing now.
Thank y'all!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #684.
On MySQL 9.4+,
--execute "SOURCE {path}"is no longer supported.