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

Identifiable!, BelongsTo!, HasMany! are brocken when used with custom_derive #430

Closed
weiznich opened this Issue Sep 6, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@weiznich
Contributor

weiznich commented Sep 6, 2016

Using one of those 3 macros with custom_derive will result in the following error:

error: expected ident, found ,
  --> <diesel macros>:21:25
   |
21 | Identifiable ! { $ args , fields = [ $ ( $ fields ) * ] , } } ; (
   |                         ^

Example Code:

custom_derive! {
     #[derive(Identifiable)]
     #[table_name(users)]
     struct User {
         id: i32,
         name: String,
     }
}

This is most likely caused by custom_derive not passing custom attributes down to the macro. The documentation mentions clearly:

"Secondly, the macro is passed the entire item, _sans attributes_. It is the derivation macro's job to parse the item correctly."

We should change the syntax here to something like:

custom_derive! {
     #[derive(Identifiable(table_name=users))]
     struct User {
         id: i32,
         name: String,
     }
}

weiznich added a commit to weiznich/diesel that referenced this issue Sep 7, 2016

@sgrif

This comment has been minimized.

Member

sgrif commented Sep 12, 2016

@sgrif sgrif closed this Sep 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment