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

More cleanly handle casing for entities in endpoints #271

Open
marcua opened this issue Jan 13, 2024 · 0 comments
Open

More cleanly handle casing for entities in endpoints #271

marcua opened this issue Jan 13, 2024 · 0 comments

Comments

@marcua
Copy link
Owner

marcua commented Jan 13, 2024

In #269, we addressed the issue raised in #266 where we weren't properly lowercasing entity slugs before looking them up in the database. At the moment, we manually lowercase every entity slug (whether they are in headers or paths), but this is error-prone and should happen implicitly. @sofiaritz shared some thoughts about how to do this cleanly:

About how should we approach the lowercasing, I think the best way is to create a struct like LowercaseString that implements From<String> and FromStr and that can be used in the database models to ensure that everything that goes into the database is lowercased. That would require implementing the Serialize and Deserialize traits manually, but I think we already do that somewhere and this isn't really complex to implement tbh.

We should also implement the Defer trait to automagically convert LowercaseString into a &str, this usually isn't a best practice (generally this is a really bad idea because implicit conversions are mostly undesired), but the String type does this which means that we probably should do it too.

@marcua marcua moved this to To do in ayb roadmap Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To do
Development

No branches or pull requests

1 participant