cornucopia-rs / cornucopia

Generate type-checked Rust from your PostgreSQL.
Other
759 stars 31 forks source link

Type hints #142

Closed cyannuk closed 1 year ago

cyannuk commented 1 year ago

Is it possible to implement some kind of type hints for generated types? Something like this:

 --: Author(age?:MyDateTime)
LouisGariepy commented 1 year ago

While the suggestion is interesting, it hasn't been implemented because there is no way for Cornucopia to tell what MyDateTime is or how it should convert a OffsetDateTime into a MyDateTime (for example).

The canonical way of doing this in Cornucopia would be to use row-mapping.

We're always keen to try new ideas, so please let me know if I didn't understand your question properly, or you have further proposals regarding this issue.

Cheers!

LouisGariepy commented 1 year ago

@cyannuk Do you still need help with this issue? I don't want to close the issue since I think the idea is interesting, but I might move it to the discussion section because this is not really something we can act upon without further information.

Cheers :smile: