You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have the proc_macro feature enabled and use Diesel's codegen derives, you will (usually) get compilation errors like:
cannot find attribute macro 'table_name' in this scope.
I realized that I wasn't having the same issue with serde's derive/attributes, and discovered that it is because, when proc_macro is enabled, it only allows the set of whitelisted attributes for the first derived trait. So if you use only #[derive(Queryable) (or any one trait), you are fine. If you #[derive(Queryable, Identifiable) you will get an error.
I think this has to be a bug in proc_macro. This can be worked around in Diesel by putting all the possible attributes in each attribute set, for example in diesel_codegen like:
However, if you need custom derives on a struct from both Diesel and, say, serde, you would be in trouble; only the top level attributes from one library or the other could be applied.
See rust-lang/rust#44925 for some more details. This is not a bug in Diesel, but I am putting it here for discussion or in case anyone runs into the same issue and needs a quick fix.
The text was updated successfully, but these errors were encountered:
If you have the
proc_macro
feature enabled and use Diesel's codegen derives, you will (usually) get compilation errors like:I realized that I wasn't having the same issue with serde's derive/attributes, and discovered that it is because, when
proc_macro
is enabled, it only allows the set of whitelisted attributes for the first derived trait. So if you use only#[derive(Queryable)
(or any one trait), you are fine. If you#[derive(Queryable, Identifiable)
you will get an error.I think this has to be a bug in
proc_macro
. This can be worked around in Diesel by putting all the possible attributes in each attribute set, for example indiesel_codegen
like:However, if you need custom derives on a struct from both Diesel and, say, serde, you would be in trouble; only the top level attributes from one library or the other could be applied.
See rust-lang/rust#44925 for some more details. This is not a bug in Diesel, but I am putting it here for discussion or in case anyone runs into the same issue and needs a quick fix.
The text was updated successfully, but these errors were encountered: