Skip to content
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

#[derive(Item)] fails silently when #[dynomite(partition_key)] missing #79

Closed
emturner opened this issue Sep 20, 2019 · 4 comments
Closed
Labels
good first issue Good for newcomers

Comments

@emturner
Copy link

emturner commented Sep 20, 2019

related: #64, #65

🐛 Bug description

#[derive(Item)] on struct <name> requires a field to have the #[dynomite(partition_key)] applied to it (as per the docs). However, when this is missing, the derive fails silently, leading to the slightly cryptic error message:
the trait 'dynomite::Item' is not implemented for '<name>' when trying to derive Item for another struct of which <name> is a member

🤔 Expected Behavior

the following should produce an error (that #[derive(Item)] requires #[dynomite(partition_key)] on a field:

use dynomite::{Item, Attribute};

#[derive(Item, PartialEq, Debug, Clone)]
pub struct Author {
    //#[dynomite(partition_key)]
    name: String,
}
 
#[derive(Item, PartialEq, Debug, Clone)]
pub struct Book {
    #[dynomite(partition_key)]
    title: String,
    author: Author,
}

uncommenting the #[dynomite(partition_key)] then compiles

👟 Steps to reproduce

run cargo check on a crate containing the above

🌍 Your environment

dynomite version: 0.6.0

rustc version: 1.39.0-nightly

@softprops
Copy link
Owner

Thanks for reporting the issue. This may be a recent regression. This sounds like a bug

@softprops
Copy link
Owner

Thinking this case could be caught and reported somewhere around here

@softprops softprops added the good first issue Good for newcomers label May 16, 2020
@softprops
Copy link
Owner

I'm in this area of the code for another issue so I think I'm going to grab this for the next release. To demonstrate how bad the current UX is here's an example of removing the partition_key attribute.

error[E0277]: the trait bound `std::option::Option<std::vec::Vec<Author>>: dynomite::Attribute` is not satisfied
  --> dynomite/examples/demo.rs:29:10
   |
29 | #[derive(Item, Debug, Clone)]
   |          ^^^^ the trait `dynomite::Attribute` is not implemented for `std::option::Option<std::vec::Vec<Author>>`

compiler errors show be informative and tell you how to fix an issue. This is neither!

@softprops
Copy link
Owner

fixed in #115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants