Rewrite #[derive(Identifiable)]
in derives2
#1526
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The actual derive itself is pretty straightforward (this isn't exactly a
complex trait). Most of the tests were brought over from the macro
tests. I dropped a few that were obviously redundant (that were testing
our struct parser not the derive). I've added a few for things that
weren't working before (and were actually broken) like tuple structs.
This does contain what is technically a breaking change in behavior. The
old implementation would look for the PK fields by field name rather
than column name. I consider this a bug. Everything else links by column
name, and if we actually went by field name, tuple structs couldn't
work.
I didn't add explicit UI tests for the table not being in scope, or for
bad syntax, as those are redundant with AsChangeset. We did have to do a
little bit of dancing to work around
rust-lang/rust#47941 when the PK names cause
an error.