Skip to content
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

Allow structs to be annotated with #[table_name="foo"] #87

Merged
merged 1 commit into from
Jan 12, 2016

Conversation

sgrif
Copy link
Member

@sgrif sgrif commented Jan 12, 2016

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't
actually have a way to go look at the annotations on Bar (at least not
as 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 the
association name, not the foreign struct that we look for.

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't
actually have a way to go look at the annotations on `Bar` (at least not
as 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 the
association name, not the foreign struct that we look for.
@sgrif
Copy link
Member Author

sgrif commented Jan 12, 2016

@mcasper @mfpiccolo review?

@mcasper
Copy link
Contributor

mcasper commented Jan 12, 2016

Looks good to me 👍 Thanks for working on that so quickly!

sgrif added a commit that referenced this pull request Jan 12, 2016
Allow structs to be annotated with `#[table_name="foo"]`
@sgrif sgrif merged commit bfcc808 into master Jan 12, 2016
@sgrif sgrif deleted the sg-table-name branch January 12, 2016 23:26
@sgrif
Copy link
Member Author

sgrif commented Jan 12, 2016

No problem. I'm not planning on releasing another version until either #88 or #89 are resolved, so let me know if you're able to point at git for everything

@mcasper
Copy link
Contributor

mcasper commented Jan 12, 2016

Yep, no problems with pointing to git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants