Skip to content

Diesel procedural macros for auto-implementing FromSql and ToSql traits for PostgreSQL enum types

License

Notifications You must be signed in to change notification settings

korir248/to-from-sql-derive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Diesel Enum Derive Macro

Overview

A Rust procedural macro library that provides custom derive macros FromSqlDerive and ToSqlDerive for seamless PostgreSQL enum serialization and deserialization with Diesel ORM.

Features

  • Automatically implement FromSql and ToSql traits for PostgreSQL enum types
  • Simple attribute-based configuration
  • Works with unit variants of enums
  • Supports custom SQL type specification

Installation

Add to your Cargo.toml:

[dependencies]
diesel-enum-sqltype = "0.1.5"
diesel = { version = "x.x.x", features = ["postgres"] }

Usage

#[derive(FromSqlDerive, ToSqlDerive)]
#[diesel(sql_type = "YourCustomSqlType")]
enum MyEnum {
    Variant1,
    Variant2,
    Variant3,
}

Limitations

  • Only supports enums with unit variants
  • Requires explicit sql_type attribute

License

MIT

Contributing

Contributions welcome! Please open an issue or submit a pull request.

About

Diesel procedural macros for auto-implementing FromSql and ToSql traits for PostgreSQL enum types

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages