Open smithwinston opened 5 years ago
If nothing else, we should definitely fix the empty schema file issue.
FYI, I ran in the same problem (unused_imports
warning with custom import_types
).
I fixed it by using a patch file, like suggested, but I manually wrote a "cleaner" one:
--- src/schema.rs
+++ src/schema.rs
@@ -0,0 +0,2 @@
+#![allow(unused_imports)]
+
I customized the patch file a little more to add some comments about the file being auto-generated, it's working great !
Not sure if this covers all cases, but adding a module-scoped lint to the module declaration like so
// lib.rs
// ...
#[allow(unused_imports)]
mod schema;
// ...
solved the issue for me without the need to edit schema.rs
at all.
@jshxr Yes that's the correct solution for any lint showing warnings inside of schema.rs
. The other issue mentioned in the bug report remains unfixed and should probably be fixed. PR's are welcome there.
Proposal
Add a new
directives
option todiesel.toml
to allow for compiler directives to be injected intoschema.rs
duringinfer_schema
:Background
It seems that many people end up with warnings about unused imports when building; the current solution is to create a
schema.patch
file as follows:And include in the
diesel.toml
as follow:As per:
https://gitter.im/diesel-rs/diesel?at=5c74378a66e2b3118b186be7
However, when reverting migrations, when the
schema.rs
file becomes empty, errors are reported because it cannot apply the patch to an empty file:While these errors don't matter (aside from littering the directory with
.orig
and.rej
files), it could break automation / scripting as the resulting value of$?
after thediesel migration revert
is now1
instead of0
indicating success.