Closed Jaymon closed 1 year ago
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
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:
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, thenField.interface_name
could be called in that method to return the right name for the db.