Module: ActiveRecordShards::SqlComments::Methods
- Defined in:
- lib/active_record_shards/sql_comments.rb
Instance Method Summary collapse
Instance Method Details
#execute(query, name = nil) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/active_record_shards/sql_comments.rb', line 5 def execute(query, name = nil) shard = ActiveRecord::Base.current_shard_selection.shard shard_text = shard ? "shard #{shard}" : 'unsharded' replica = ActiveRecord::Base.current_shard_selection.on_replica? replica_text = replica ? 'replica' : 'primary' query = "/* #{shard_text} #{replica_text} */ " + query super(query, name) end |