Allow structs to be annotated with #[table_name="foo"]
#87
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.
This is related to #86, where we are not properly inferring the table
name for some structs. While I do want to actually fix some of the cases
in that issue, it's also been pointed out that we don't handle any edge
cases for pluralization.
I might improve pluralization slightly, but we're not going to
maintain an actual mapping of every word as it's brittle, difficult to
maintain, and causes bug fixes to stop people's code from compiling.
Regardless of how good our inference is, we should decouple the table
name from the struct name. This now allows specifying the table name
with an annotation. This does not affect any public API, only
associations which I have not made public or documented as they're still
very prototypical.
It should be noted that this only affects other annotations on the
same struct. When we're processing an annotation on
Foo
, we don'tactually have a way to go look at the annotations on
Bar
(at least notas far as I can tell). At this point in time, we do not directly
reference any struct in a way that should be affected by this.
#[belongs_to]
comes close, but the table name is based on theassociation name, not the foreign struct that we look for.