sfackler / rust-postgres

Native PostgreSQL driver for the Rust programming language
Apache License 2.0
3.5k stars 443 forks source link

Feature request: `rename_all` container attribute #934

Closed allan2 closed 1 year ago

allan2 commented 2 years ago

A Postgres type like so

CREATE TYPE mood AS ENUM ('sad', 'happy');

can be represented like this

#[derive(ToSql, Debug)]
#[postgres(name = "mood")]
enum Mood {
    #[postgres(name = "sad")]
    Sad,
    #[postgres(name = "happy")]
    Happy
}

This is a request for a container attribute like Serde's rename_all [1]

#[derive(ToSql, Debug)]
#[postgres(rename_all = "lowercase")]
enum Mood {
    Sad,
    Happy
}

What do you think?

--

894 related

sfackler commented 2 years ago

Seems like a reasonable feature to me!

jakubadamw commented 2 years ago

@allan2 @sfackler I made an attempt at an initial implementation in #952. Feedback would be welcome!

allan2 commented 1 year ago

Closing because merged in #1008 and released in postgres-types 0.2.6. Thanks @JaydenElliott @sfackler!