diesel-sqlite-enum-integer 0.1.0

This proc macro attribute will allow you to store the enum as integer.
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 5.72 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 269.66 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Salman-Sali

Note: This proc macro derive will only work if your enum does not contain any variant which accepts values.

Your cargo.toml

[dependencies]

num_enum = "*"

diesel = { version = "*", features = ["sqlite"] }

Your enum

#[diesel_sqlite_enum_integer::enum_to_diesel_integer]
pub enum MyEnum {
    One,
    Two,
    Three
}

The database entity

#[diesel(table_name = crate::schema::my_entity)]
#[derive(Debug, Queryable, Selectable, Identifiable, Associations, PartialEq, Insertable)]
pub struct MyEntity {
    pub id: i32,
    pub my_enum: MyEnum
}

The schema

diesel::table! {
    my_entity (id) {
        id -> Integer,
        my_enum -> Integer
    }
}