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

Suggestion: custom struct attributes #67

Open
LukasLohmar opened this issue Sep 4, 2024 · 1 comment
Open

Suggestion: custom struct attributes #67

LukasLohmar opened this issue Sep 4, 2024 · 1 comment

Comments

@LukasLohmar
Copy link

i ran into an issue with sqlite.
the generated struct needs #[diesel(check_for_backend(diesel::sqlite::Sqlite))] attribute to compile and it seems there is no way to set it right now

i figured it would be pretty awesome to have the possibility to add any attribute we want to our generated structs

inside my fork its already implemented and works like the following:

diesel_ext.exe --import-types "crate::schema::*" --derive "AsChangeset, Insertable, Queryable, Selectable, Debug" --struct-attribute "#[diesel(check_for_backend(diesel::sqlite::Sqlite))]" --add-table-name --model > src/database/src/models.rs

#[derive(AsChangeset, Insertable, Queryable, Selectable, Debug)]
#[diesel(table_name = user_tokens)]
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
pub struct UserToken {
    pub id: Option<i32>,
    pub user_id: Vec<u8>,
    pub token: Vec<u8>,
    pub lifetime: Option<NaiveDateTime>,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@LukasLohmar and others