-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Prevent name collision for teams #83
base: master
Are you sure you want to change the base?
Prevent name collision for teams #83
Conversation
71ac969
to
63e08aa
Compare
63e08aa
to
388c520
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this and would like this to move forward. Thanks.
- I think the configuration option should be called
store_teams_in
(or better name?) and have downstream effect on both Mongoid and ActiveRecord. In MongoDB there are no "tables", but "collections". - This is not backwards compatible and will break anyone with a
Team
class, I believe. I have half a dozen bots that extend theTeam
. Give it a try on anything like http://github.com/dblock/slack-strava and you'll see what I mean. At the very least we need UPGRADING to explain what one should do. But I think the right long term solution is that rather than namespacing the team class we want to turn it into a module that can be included in both Mongoid and AR scenarios. In which case we don't actually need to specify the table name, this would be the responsibility of the class using the module.
What do you think?
I feel like importing another module will add unnecessary complexity, and easy fix for those that subclass Teams is just to add As for the name of the variable to store the table name, I prefer Using something like I don't mind either way, it just makes more sense to me to have the variable as the noun of what it is, like |
Except that there're no "tables" in MongoDB, so it only makes sense for AR. In MongoDB these are called "collections". |
So which would you prefer?
Did you want the mongoid patch before accepting this PR? |
I think the cleanest and most forward-looking solution is a
This way future we can extend this in the future. What do you think?
I'd like Mongoid to work as part of this PR as well, but would accept without it. |
so, |
What if we just dropped
This way it's extensible for the future, for example
|
Did you mean something like this? I'm fine with it this way, since it'll read off as "configure the teams to have name 'my_table'". Only potential issue with this is consistency, since this is the only place where it's configured like this. Let me know about the final call and I'll make the updates. |
that LGTM |
This needs a major version bump. If you have time, consider doing the MongoDB support for renaming the collection as part of this. Try writing/upgrading a trivial bot. I personally only have MongoDB ones. |
UPGRADING.md
Outdated
@@ -1,6 +1,10 @@ | |||
Upgrading Slack-Ruby-Bot-Server | |||
=============================== | |||
|
|||
### Upgrading to >= 0.8.3 | |||
|
|||
To avoid name collisions, `Team` has been renamed `SlackRubyBot::Team`, if you modify the class `Team` add `Team = SlackRubyBot::Team` before the code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should say SlackRubyBotServer
not SlackRubyBot
, right?
Also, I could be wrong, but I think this might not work for MongoDB because it might change the name of the collection to something like slack_ruby_bot_server_team
, that needs to be tested, so I suggest you actually do the change for mongodb as part of this PR, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya, my bad. I'll get that changed.
Sure, I can test out MongoDB, but it might take a while though.
Just noticed that more changes needs to be done for this feature, since the db:migrate doesn't pull in the setting of tablename for ActiveRecord. Will continue to work on this. |
I still think turning |
Related #102, in which the user tried to inherit from |
Prevents name collision for teams so that the gem can be used with other projects.
Team
. References to teams are nowSlackRubyBotServer::Team
SlackRubyBotServer::Config.teams[:name]='my_table'
Minor bug fixes: