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
use attribute name as symbol in hash, without table name, for activerecord scopes #289
Conversation
@scambra Could you explain what you mean with "database.table_name.status, instead of database.table_name.status", please? |
I didn't see ` was removed on my comment, it should be clearer now |
Hmm, it wasn't about the formatting, more about the content. You say, it generates wrong SQL X, and it should provide rather Y. But in your example, X and Y are the same. |
Ah no, I'm wrong. Sorry. Now it's clearer. |
@scambra Sorry, it's been a while. Do you mind merging the current master back into your fork? |
…name.attribute" => name
rebased |
@scambra Sweet, thanks a lot! |
use attribute name as symbol in hash, without table name, for activerecord scopes
Thanks |
I just released version |
I have self.table_name = 'database.table' in my AASM model, because I do sharding and change database connected on ActiveRecord::Base on every request, but for AASM model I want to use the main database always, so I set in the table name so I don't need to establish new connection.
However, setting conditions with "#{@klass.table_name}.#{@klass.aasm(@name).attribute_name}" generates wrong SQL:
If conditions uses column name as symbol, such as {:status => name.to_s}, activerecord generates right SQL, including table name (and database in my case).