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

mapping between orm_fieldname and interface_fieldname #154

Closed
Jaymon opened this issue Jan 26, 2023 · 1 comment
Closed

mapping between orm_fieldname and interface_fieldname #154

Jaymon opened this issue Jan 26, 2023 · 1 comment
Labels

Comments

@Jaymon
Copy link
Owner

Jaymon commented Jan 26, 2023

Recently I needed to mess with a table with column names in camel case (eg, fooBar) but I wanted to keep the model fields in snake case (eg, foo_bar) so I looked into passing a param into field, something like this:

foo_bar = Field(str, interface_name="fooBar")

and then just having everything magically work. I think this is possible, but it will take some refactoring. I think I could hook into Interface._normalize_name by having it take a Field instance or a Schema instance. But I would need to change up the interface to always have the Field instance close, then Field.interface_name could be called in that method to return the right name for the db.

@Jaymon Jaymon added the invalid label Mar 11, 2023
@Jaymon
Copy link
Owner Author

Jaymon commented Mar 11, 2023

Honestly, Field's aliasing funcitonality basically did this, I just had to reverse it:

fooBar = Field(str, alias="foo_bar")

Worked exactly how I wanted, the fooBar was in the db and I could use foo_bar everywhere in the codebase

@Jaymon Jaymon closed this as completed Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant