kurtbuilds / ormlite

An ORM in Rust for developers that love SQL.
https://crates.io/crates/ormlite
MIT License
216 stars 11 forks source link

proc-macro derive panicked message: `"r#type"` is not a valid identifier #32

Open holmofy opened 11 months ago

holmofy commented 11 months ago
#[derive(Debug, Model)]
#[ormlite(table = "schedule_config")]
pub struct ScheduleConfig {
    #[ormlite(primary_key)]
    pub id: i64,
    pub user_id: i64,
    pub store_id: i64,
    pub proxy_id: i64,
    pub r#type: SchedulerType,
    pub finished: bool,
    pub cron: String,
}

This r#type field cannot be processed by macros.

error: proc-macro derive panicked
 --> src/model/data_store_meta.rs:7:24
  |
7 | #[derive(Clone, Debug, Model)]
  |                        ^^^^^
  |
  = help: message: `"r#type"` is not a valid identifier
kurtbuilds commented 11 months ago

Thank you for reporting this. This is a straight forward bugfix, that I will get to, though I'm on vacation right now. Easy workaround should be naming the column to typ or similar, and using a #[ormlite(column = "type")] attribute.