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

Dev/ksmihtson/pluralize table name #144

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

smitt04
Copy link

@smitt04 smitt04 commented Jan 8, 2014

I have some tables that use singular table names so I added the ability to turn off pluralizing table names for sql adapters

@mde
Copy link
Contributor

mde commented Jan 8, 2014

Could we figure out why this breaks the tests in CI? Also, would it make more sense to add a general feature for allowing you to override the table-name for each model?

@smitt04
Copy link
Author

smitt04 commented Jan 8, 2014

Yea, I will look into why the tests don't pass. I was originally thinking of adding a way to override the tableName on the model level, but then I got to thinking.

  1. I didn't want to have to override each tableName for every model, especially for a standard (see Indexes and Browser Support #2)
  2. I also thought that the singular vs plural table names is more of a standard you would have across a project, so it seemed to make more since on the adapter level.
  3. Only SQL adapters have table names, it would be a useless property for nosql, where those could be collectionName or something similar and didnt want it to be confusing across adapters. (but we could standardize that)

If you think it would be a good idea I could always add tableName to the model level in addition to the pluralizeTableName

@mde
Copy link
Contributor

mde commented Jan 8, 2014

I can see where it would be a pain in the ass to override for every single table, if you're doing it according to a pattern, but I do think a general override for the table-name might be more generally useful. It's a feature that's been requested before. The purpose of that is for dealing with legacy DBs, where you can't follow the existing convention, not really when your personal sense of aesthetics conflicts with the convention. Every configuration option we add adds complexity that we have to test and maintain. Is singular table-names something you really need? :)

@smitt04
Copy link
Author

smitt04 commented Jan 8, 2014

I pushed the fix for the tests to pass. I can see why you don't want to add an option for changing the convention for the ORM models, expecially when you are mainly using it in geddy and would like a standard. But my company is trying to add the model support into our own custom framework and would like to be able to set our own standard for table names. If there was some way we could do that easily it would be nice. It was my boss who suggested the idea about the plurizeTableNames. I can talk to him tomorrow and see if he is open to changing db names. Even if there was a way to override _tableizeModelName on our framework level, then that might work. otherwise that is why i implemented the pluralizeTableNames setting.

@mde
Copy link
Contributor

mde commented Jan 8, 2014

It would be awesome if y'all were open to joining with us using the same convention. Any time there's a one-off, it ends up being an ongoing source of minor bugs (here's a great post on the cost of engineering complexity: http://firstround.com/article/The-one-cost-engineers-and-product-managers-dont-consider). And there's real value in doing things the expected way. Considering the cost/benefit of these things almost always leads to a better outcome -- what's the actual, practical value of making this change?

It certainly would be possible to override the pseudo-private _tableizeModelName method, but it could be a little bit messy.

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.

None yet

2 participants