pg_cache_key 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a22d3542adbbdf55f3f09a4cb510986b50d5e87
4
- data.tar.gz: a8bcb86f6338109deb7c09905d5241aa0f568550
3
+ metadata.gz: 6de9641f70be650b00f1aea66b0b19c4b805183b
4
+ data.tar.gz: b3d53d547d4bcc550bebb5f9b5575c06498b2e6a
5
5
  SHA512:
6
- metadata.gz: 37ad5b28ebc8351f40fe50cc8523d446897d1d179ce7533f25a3912dc37619f468b78e733200c3ed80559672d59bae58dd359ca21a732798ce5e672d9e17ca88
7
- data.tar.gz: b4089abc9ac26384361d95224b7358d48378a136e23498427afae6a6256e383d92e8bbaf7a5fab8eecc12a5b88cafd70358ea5058995e183d8df1987ccc43c11
6
+ metadata.gz: ab9e30ce53ffe894d2ece3af511d0e947b65055582814440f64649ded86e41c4769bcb9aa361fec35dec7660460c58babc4d86a7b39dd0fe0903cc08a00c2030
7
+ data.tar.gz: d0ff6f9564c326282ec1d884fd84d7f1583318f53c8fbf0dd9838a49fb00d0ecdae2794f5541fa4ab923493db32743b8e1cc688e7b44ee297f9bb9b3fc9b03f8
data/lib/pg_cache_key.rb CHANGED
@@ -20,14 +20,13 @@ module ActiveRecord
20
20
  # = Active Record \Relation
21
21
  class Relation
22
22
  def cache_key(timestamp_column = :updated_at)
23
- cache_columns = [timestamp_column, :id]
24
23
  @cache_keys ||= {}
25
-
26
24
  # Rem 1: why use connection.execute instead of doing collection.select because of an order. if you using some order on your scope
27
25
  # then columns you using to order must appear in the GROUP BY clause or be used in an aggregate function or you will get an error
28
26
  # Rem 2: we need to add select( cache_columns ) explicitly because if relation has includes it might transform columns to aliases
29
- @cache_keys[timestamp_column] ||= connection.execute( "SELECT md5(string_agg( #{cache_columns.map{|fld| "\"t\".\"#{fld}\"::text" }.join('||')}, '') ) as cache_key
30
- FROM (#{ select(cache_columns).try(:to_sql) }) t" )[0]['cache_key']
27
+ @cache_keys[timestamp_column] ||= connection.execute(
28
+ "SELECT md5(string_agg( t.cc_#{timestamp_column}||t.cc_id, '') ) as cache_key
29
+ FROM (#{ select( [timestamp_column, :id].map{|cc| "#{table_name}.#{cc}::text as cc_#{cc}" } ).try(:to_sql) }) t" )[0]['cache_key']
31
30
  end
32
31
  end
33
- end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module PgCacheKey
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_cache_key
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - alekseyl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-23 00:00:00.000000000 Z
11
+ date: 2016-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord