#1720·loco

Support having custom field types on models when using entity generation

Author: felipesereCreated Dec 31, 2025Updated Jul 29, 2026
Labelsenhancement

Feature Request

Is your feature request related to a problem? Please describe.

I'm migrating my backend from PostgreSQL to SQLite and I need to use JsonStringVec(Vec<String>) to model an array of tags (for food ingredients and recipes). I could use Json but that spills everywhere. If I use JsonStringVec(...) I can implement to_vec() and .into() to make mapping intuitive. The downside of a custom newtype: the moment I run generate for some other field I loose my type. Upshot: it does not compile, so I know that I have to do something. Downside: I have to go do something.

Describe the solution you'd like

Ideally there would be a way to say "this column should be mapped to this Rust type" and then its up to the application code to make sure all traits are implemented. To be clear, I don't expect the traits needed for the mapping to be automagically implemented. Its enough that the overwritten file keeps compiling after running cargo loco db entities

Describe alternatives you've considered

At the moment I am just manually remembering to do it. I got stung twice already, but its strictly speaking not the worst...