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 +4 -4
- data/lib/pg_cache_key.rb +4 -5
- data/lib/pg_cache_key/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6de9641f70be650b00f1aea66b0b19c4b805183b
|
4
|
+
data.tar.gz: b3d53d547d4bcc550bebb5f9b5575c06498b2e6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
30
|
-
|
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
|
data/lib/pg_cache_key/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|