sfackler / rust-postgres

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

added `rename_all` container attribute for enums and structs #1008

Closed JaydenElliott closed 1 year ago

JaydenElliott commented 1 year ago

Related issue: #934

Adding a rename_all attribute to a struct or enum will rename the container's fields/variants according to the rule specified. Similar to serde's rename_all but for use with ToSql and FromSql.

This removes the need to manually rename each field/variant before inserting/selecting from postgres (especially useful with enums, who's naming standards differ from rust).

Supported rules:

No external dependencies introduced. Case conversion code from serde was used.

Thanks @jakubadamw for the test cases from #952

sfackler commented 1 year ago

Can you also update the documentation here? https://github.com/sfackler/rust-postgres/blob/master/postgres-types/src/lib.rs

LGTM otherwise

JaydenElliott commented 1 year ago

Can you also update the documentation here? https://github.com/sfackler/rust-postgres/blob/master/postgres-types/src/lib.rs

LGTM otherwise

@sfackler Documentation added, see f4b181a20180f1853351be53a32865b6209d0ab4

JaydenElliott commented 1 year ago

can this be approved + merged @sfackler ?

kitsuniru commented 1 year ago

we waiting for u, @sfackler

sfackler commented 1 year ago

Thanks! Sorry for the delay