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

Add a container-level rename_all attribute to FromSql/ToSql #952

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jakubadamw
Copy link
Contributor

It works both with composite types' fields and enum variants, although arguably it will be the most useful for the latter as that's where the naming conventions between Rust and a typical PostgreSQL schema differ.

Right now it supports the following casing styles, following serde:

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

Addresses #934.

@jakubadamw
Copy link
Contributor Author

So this adds a few dependencies to keep the implementation concise. I, personally, subscribe to the “use as much of the crates.io ecosystem as you can possibly can” philosophy, but I can see how it may not be appropriate for the project. Still, that's what I did in the first version to gather feedback. Which dependency should be got rid of can perhaps be decided later.

It works both with composite types' fields and enum variants, although
arguably it will be the most useful for the latter as that's where
the naming conventions between Rust and a typical PostgreSQL schema differ.

Right now it supports the following casing styles:

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

mimicking Serde.
@jakubadamw jakubadamw force-pushed the 934-container-attribute-rename-all branch from 4b6e704 to f09d450 Compare September 24, 2022 19:13
@jakubadamw jakubadamw marked this pull request as ready for review September 28, 2022 17:11
@allan2
Copy link

allan2 commented Oct 24, 2022

Since this is a library, I think it would be better to avoid introducing external dependencies to keep compile times down.

@sfackler thoughts?

The case conversion code in serde_derive might be helpful.

@JaydenElliott
Copy link
Contributor

@jakubadamw are you still working on this, would love this feature

@jakubadamw
Copy link
Contributor Author

@JaydenElliott hey, not really, no. I'll be happy for someone else to take over this. 🙂

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.

None yet

3 participants