Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign up[Proposal] type sizes in diesel schema #1713
Comments
This comment has been minimized.
|
Thanks, but this isn't something I want to have Diesel care about or try to enforce right now. This is no different than other forms of constraints. You can just as easily have an arbitrary check constraint that we have no way of handling. Additionally, we have no way to try and enforce this at compile time. There's no type that represents a fixed length string in Rust. |
sgrif
closed this
May 22, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
trsh commentedMay 22, 2018
•
edited
In my application (REST, GraphQL, etc.) I want field restrictions being closely tighten up with DB field restrictions. For example, if a DB field is Varchar(100), then my application should also push restriction of 100 symbols for a input, that will be stored in this field.
Right now I have to control this manually. If I change DB field size restriction via migrations, I have to remember also to change restrictions in my application.
Solution. let the generated Schema include also sizes:
And let this size be accessible via .dsl::id.size() (orsmth like that).