-
Notifications
You must be signed in to change notification settings - Fork 108
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
FromRow depends on the struct having the same layout as table. #370
Comments
Hello and Happy New Year! (pardon us for the delay, everybody was celebrating) The only reasons are performance and ease of development - if we assume the layout to have the same order as the table definition, we save time and effort on matching column names to struct names and validating if everything matches. I agree though that it would be nice to optionally allow (perhaps with a separate macro) a matching based on names instead, since that's what users might find more friendly to use. |
Ah that makes sense. Although i wonder how much of an effect the additional overhead would have on performance. Especially on smaller structs. |
@ChillFish8 Note that you can generate every table definition into rust |
We'll be moving away from This should be covered after this PR is merged and finished: #665 |
@piodul will the verification of the fields be optional? What I mean with that, is that I want to make sure Catalytic remains up to date by using this new derive macro, but since the code is generated, it does not need these checks. So it would be nice if there is a method called something like ‘deserialize_unsafe’ or whatever which skips these columns checks, which I can call with Catalytic. |
In the current state of the PR - no, but I will add an attribute for the derive macro so that the name check can be disabled. |
FromRow
when derived depends on the struct fields matching the same layout as the table itself, which can be a little interesting to deal with when you would expect that it bases it off of the column name as the majority of other databases drivers in Rust.Is there any particular reason why it depends on having the struct mirror the layout of the table vs getting each field by column name?
The text was updated successfully, but these errors were encountered: