Derive Macro diesel_derive_enum::DbEnum

source ·
    // Attributes available to this derive:
Expand description

Implement the traits necessary for inserting the enum directly into a database


Type attributes

  • #[ExistingTypePath = "crate::schema::sql_types::NewEnum"] specifies the path to a corresponding diesel type that was already created by the diesel CLI. If omitted, the type will be generated by this macro. Note: Only applies to postgres, will error if specified for other databases
  • #[DieselType = "NewEnumMapping"] specifies the name for the diesel type to create. If omitted, uses <enum name>Mapping. Note: Cannot be specified alongside ExistingTypePath
  • #[DbValueStyle = "snake_case"] specifies a renaming style from each of the rust enum variants to each of the database variants. Either camelCase, kebab-case, PascalCase, SCREAMING_SNAKE_CASE, snake_case, verbatim. If omitted, uses snake_case.

Variant attributes

  • #[db_rename = "variant"] specifies the db name for a specific variant.