diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2016-09-22 15:00:30 +0200 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2016-09-22 15:30:45 +0200 |
commit | 84d35da86c14767c737783cb95dd4624632cc1bd (patch) | |
tree | 487f03efc3f82c571c7bc6510f58554dfbfaeecc /activerecord/lib/active_record/connection_adapters | |
parent | 19966242163611e61d45ee4033f28aa6f967906a (diff) | |
download | rails-84d35da86c14767c737783cb95dd4624632cc1bd.tar.gz rails-84d35da86c14767c737783cb95dd4624632cc1bd.tar.bz2 rails-84d35da86c14767c737783cb95dd4624632cc1bd.zip |
Preserve cached queries name in AS notifications
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb index 6ca53c72ce..2f8a89e88e 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb @@ -65,7 +65,7 @@ module ActiveRecord if @query_cache_enabled && !locked?(arel) arel, binds = binds_from_relation arel, binds sql = to_sql(arel, binds) - cache_sql(sql, binds) { super(sql, name, binds, preparable: preparable) } + cache_sql(sql, name, binds) { super(sql, name, binds, preparable: preparable) } else super end @@ -73,11 +73,17 @@ module ActiveRecord private - def cache_sql(sql, binds) + def cache_sql(sql, name, binds) result = if @query_cache[sql].key?(binds) - ActiveSupport::Notifications.instrument("sql.active_record", - sql: sql, binds: binds, name: "CACHE", connection_id: object_id) + ActiveSupport::Notifications.instrument( + "sql.active_record", + sql: sql, + binds: binds, + name: name, + connection_id: object_id, + cached: true, + ) @query_cache[sql][binds] else @query_cache[sql][binds] = yield |