Fix missing error information when running embedded migrations.#1993
Closed
sorccu wants to merge 1 commit intodiesel-rs:masterfrom
Closed
Fix missing error information when running embedded migrations.#1993sorccu wants to merge 1 commit intodiesel-rs:masterfrom
sorccu wants to merge 1 commit intodiesel-rs:masterfrom
Conversation
…to lose all error information. Fixes diesel-rs#1977.
Author
|
I believe that Travis simply timed out instead of actually reporting an error. Closing and opening the PR once hoping to trigger the build again. |
Author
|
Same thing again. Trying once more. |
weiznich
requested changes
Mar 28, 2019
| } | ||
|
|
||
| fn file_path(&self) -> Option<&Path> { | ||
| Some(Path::new(self.version)) |
Member
There was a problem hiding this comment.
I think instead of returning a fake path here, we should fix the formatting to just print the version if the path is not set.
Member
|
ping @sorccu, any updates? |
geomaniac
added a commit
to geomaniac/diesel
that referenced
this pull request
Sep 2, 2019
In Display impl for`MigrationName`, use the migration version if `Migration::file_path` returns None. This is based on the work from @sorccu in diesel-rs#1993. Fixes diesel-rs#1977.
geomaniac
added a commit
to geomaniac/diesel
that referenced
this pull request
Sep 2, 2019
In Display impl for`MigrationName`, use the migration version if `Migration::file_path` returns None. This is based on the work from @sorccu in diesel-rs#1993. Fixes diesel-rs#1977.
geomaniac
added a commit
to geomaniac/diesel
that referenced
this pull request
Sep 2, 2019
In Display impl for`MigrationName`, use the migration version if `Migration::file_path` returns None. This is based on the work from @sorccu in diesel-rs#1993. Fixes diesel-rs#1977.
Member
|
Closed by #2159 |
disconsented
pushed a commit
to NarrativeApp/diesel
that referenced
this pull request
Nov 26, 2020
In Display impl for`MigrationName`, use the migration version if `Migration::file_path` returns None. This is based on the work from @sorccu in diesel-rs#1993. Fixes diesel-rs#1977.
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.
When using embedded migrations, all error information is currently lost due to a mysterious
formatting errorreplacing the actual error. The error itself is not important, as long as it happens within the migration run. For example, the following migration:up.sql
Executed with:
Will result in the following output:
What SHOULD be shown is something along the lines of:
It turns out that the reason is very simple. Upon encountering an error, diesel attempts to display the filename of the failed migration:
diesel/diesel_migrations/migrations_internals/src/lib.rs
Lines 337 to 344 in 03ec1d9
Since the embedded migration's
impl Migrationis left without afile_path()implementation:diesel/diesel_migrations/migrations_macros/src/embed_migrations.rs
Lines 37 to 49 in 03ec1d9
... it returns the default
None, which then triggers the formatting error here:diesel/diesel_migrations/migrations_internals/src/migration.rs
Lines 49 to 52 in 03ec1d9
And since the
writeln!()for the error message uses?, the formatting error from above ends up replacing the original error entirely.This PR introduces a fake path based on the version identifier that lets things proceed as usual while providing useful information.
Fixes #1977