counter_culture 3.11.1 → 3.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 593e3704f40322fade2c263f93bb6d88749b397d641586b30f4d616ee5c9ed0c
4
- data.tar.gz: b183412de943dbe2390a4eef636ca8aae9fea6aeac6ac298177545d26b08413e
3
+ metadata.gz: c568fc84225757b834a008eb60dbadfe5dea148078c855fe76a2b5711b0c5b1e
4
+ data.tar.gz: 3abc94f197b60fb6778eadb98ad402e6b961155c492970111b85bbf1bd171237
5
5
  SHA512:
6
- metadata.gz: c0a74d87a9d56ec4b19d7fe9a7aaf9bd2698d527387251a52b866e534117386005e830eef556b96bbc67122a125ebf942a4531be5b6f2d35a075b55b3133b052
7
- data.tar.gz: 4cd891261ed5402cffa7eea851e2400f3b6d7ec8c4d617b36a3b0dd680e00f17b9b1a909a55bb94db1dbe636ca4b5d2d929d02df851e00869bb316a703fa8928
6
+ metadata.gz: adfd25e90ca300e1d6bc19296b343a8fbd9a272076e48591dddc513ffa4173dff10ef2d26cec6bd08bdfbc372ccf1b94e97cee7d7827205523efe0278d1bffea
7
+ data.tar.gz: 733126919913da347057de9c81cbbdf7b4b45e9ea1bbbecad12586a06432801e37b1c8833078cc93ce11fdc0ad3b201c5484822dcebc708f970d2106c022d35b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 3.11.2 (July 10, 2025)
2
+
3
+ Bugfixes:
4
+ - Fix regression for foreign_key_values by adding support for composite primary keys (#417)
5
+
1
6
  ## 3.11.1 (June 27, 2025)
2
7
 
3
8
  Bugfixes:
data/README.md CHANGED
@@ -232,7 +232,7 @@ The ```:delta_column``` option supports all numeric column types, not just ```:i
232
232
  class Product < ActiveRecord::Base
233
233
  belongs_to :category
234
234
  counter_culture :category, foreign_key_values:
235
- proc {|category_id| [category_id, Category.find_by_id(category_id).try(:parent_category).try(:id)] }
235
+ proc {|category_id| [category_id, Category.find_by(id: category_id)&.parent_category&.id] }
236
236
  end
237
237
 
238
238
  class Category < ActiveRecord::Base
@@ -108,6 +108,15 @@ module CounterCulture
108
108
 
109
109
  primary_key = relation_primary_key(relation, source: obj, was: options[:was])
110
110
 
111
+ if foreign_key_values && id_to_change.is_a?(Enumerable) && id_to_change.count > 1 &&
112
+ Array.wrap(primary_key).count == 1
113
+ # To keep this feature backwards compatible, we need to accommodate a case where
114
+ # `foreign_key_values` returns an array, but we're _not_ using composite primary
115
+ # keys. In that case, we need to wrap the `id_to_change` in one more array to keep
116
+ # it compatible with the `.zip` call in `primary_key_conditions`.
117
+ id_to_change = [id_to_change]
118
+ end
119
+
111
120
  if Thread.current[:aggregate_counter_updates]
112
121
  Thread.current[:primary_key_map][klass] ||= primary_key
113
122
  end
@@ -1,3 +1,3 @@
1
1
  module CounterCulture
2
- VERSION = '3.11.1'.freeze
2
+ VERSION = '3.11.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: counter_culture
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.1
4
+ version: 3.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus von Koeller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-06-27 00:00:00.000000000 Z
11
+ date: 2025-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord