Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added rename_all container attribute for enums and structs #1008

Merged
merged 4 commits into from
Jun 10, 2023

Conversation

JaydenElliott
Copy link
Contributor

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:

  • "lowercase"
  • "UPPERCASE"
  • "PascalCase"
  • "camelCase"
  • "snake_case"
  • "SCREAMING_SNAKE_CASE"
  • "kebab-case"
  • "SCREAMING-KEBAB-CASE"

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

Thanks @jakubadamw for the test cases from #952

@sfackler
Copy link
Owner

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

LGTM otherwise

@JaydenElliott
Copy link
Contributor Author

JaydenElliott commented Mar 28, 2023

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 f4b181a

@JaydenElliott JaydenElliott requested a review from sfackler March 30, 2023 22:18
@JaydenElliott
Copy link
Contributor Author

JaydenElliott commented Apr 9, 2023

can this be approved + merged @sfackler ?

@kitsuniru
Copy link

we waiting for u, @sfackler

@sfackler sfackler merged commit 790af54 into sfackler:master Jun 10, 2023
@sfackler
Copy link
Owner

Thanks! Sorry for the delay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants