bullet 7.1.1 → 7.1.3

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
  SHA256:
3
- metadata.gz: f3337004db8160edc4f3fecbb4b9d9caf5db356f2bc53cbb8a87dc32661747db
4
- data.tar.gz: cf987a580af8f2451043a7ccc0ad0fd2f4f30b4832c8889e2a7891a85e1ed062
3
+ metadata.gz: 68fdd5b4a91b98bb9fa4399088979b48a0e07432f268df9f0116b413433f8e89
4
+ data.tar.gz: d7832e74768e19a93355b7d67341cebedde9f14048b331b91564ed9b218f3a4d
5
5
  SHA512:
6
- metadata.gz: 88ba85427aeb892d39b66d6f98edfa2dd1d80a23eba3080c2497b7b2b496add6cf3835239bc81b349a5176413fe771637e1218e72eca1d15b24f9f6cd737826d
7
- data.tar.gz: d3982d128702e65d65ec669be5a8ef0c15725e2f474db26911186aafedf6192f2278709cc1dee0f8d5857ca43105bb34fa6d2fa59eafaadb7b3284e5821a1388
6
+ metadata.gz: 2a8ec0d54d2d0557793b1ad53b571ff5c04345d0e699d4052649b96f08ac911d5a200058fd9c13ee3ef342da65e14229f99e6cdc6fdab65668e468a062b1debe
7
+ data.tar.gz: 4c2606728e7e84f80dbbdfc66c34510825d4b365204718a1eaaf3a42247ff9c8708d5be321ae07aad95f0ddc3e57e97961327d58f1dced9912a7c26822584b54
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## Next Release
2
2
 
3
+ ## 7.1.3 (11/05/2023)
4
+
5
+ * Call NPlusOneQuery's call_association when calling count on collectino assocation
6
+
7
+ ## 7.1.2 (10/13/2023)
8
+
9
+ * Handle Rails 7.1 composite primary keys
10
+
3
11
  ## 7.1.1 (10/07/2023)
4
12
 
5
13
  * Add support for `Content-Security-Policy-Report-Only` nonces
data/README.md CHANGED
@@ -287,17 +287,17 @@ $ rails new test_bullet
287
287
  $ cd test_bullet
288
288
  $ rails g scaffold post name:string
289
289
  $ rails g scaffold comment name:string post_id:integer
290
- $ bundle exec rake db:migrate
290
+ $ bundle exec rails db:migrate
291
291
  ```
292
292
 
293
293
  2\. Change `app/models/post.rb` and `app/models/comment.rb`
294
294
 
295
295
  ```ruby
296
- class Post < ActiveRecord::Base
296
+ class Post < ApplicationRecord
297
297
  has_many :comments
298
298
  end
299
299
 
300
- class Comment < ActiveRecord::Base
300
+ class Comment < ApplicationRecord
301
301
  belongs_to :post
302
302
  end
303
303
  ```
@@ -181,6 +181,7 @@ module Bullet
181
181
  def count(column_name = nil, options = {})
182
182
  if Bullet.start?
183
183
  Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
184
+ Bullet::Detector::NPlusOneQuery.call_association(proxy_association.owner, proxy_association.reflection.name)
184
185
  end
185
186
  super(column_name, options)
186
187
  end
@@ -173,6 +173,7 @@ module Bullet
173
173
  def count(column_name = nil, options = {})
174
174
  if Bullet.start?
175
175
  Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
176
+ Bullet::Detector::NPlusOneQuery.call_association(proxy_association.owner, proxy_association.reflection.name)
176
177
  end
177
178
  super(column_name, options)
178
179
  end
@@ -238,6 +238,7 @@ module Bullet
238
238
  def count(column_name = nil, options = {})
239
239
  if Bullet.start?
240
240
  Bullet::Detector::CounterCache.add_counter_cache(proxy_association.owner, proxy_association.reflection.name)
241
+ Bullet::Detector::NPlusOneQuery.call_association(proxy_association.owner, proxy_association.reflection.name)
241
242
  end
242
243
  super(column_name, options)
243
244
  end
@@ -269,6 +269,10 @@ module Bullet
269
269
  proxy_association.owner,
270
270
  proxy_association.reflection.name
271
271
  )
272
+ Bullet::Detector::NPlusOneQuery.call_association(
273
+ proxy_association.owner,
274
+ proxy_association.reflection.name
275
+ )
272
276
  end
273
277
  super
274
278
  end
@@ -251,6 +251,10 @@ module Bullet
251
251
  proxy_association.owner,
252
252
  proxy_association.reflection.name
253
253
  )
254
+ Bullet::Detector::NPlusOneQuery.call_association(
255
+ proxy_association.owner,
256
+ proxy_association.reflection.name
257
+ )
254
258
  end
255
259
  super(column_name)
256
260
  end
@@ -278,6 +278,10 @@ module Bullet
278
278
  proxy_association.owner,
279
279
  proxy_association.reflection.name
280
280
  )
281
+ Bullet::Detector::NPlusOneQuery.call_association(
282
+ proxy_association.owner,
283
+ proxy_association.reflection.name
284
+ )
281
285
  end
282
286
  super
283
287
  end
@@ -278,6 +278,10 @@ module Bullet
278
278
  proxy_association.owner,
279
279
  proxy_association.reflection.name
280
280
  )
281
+ Bullet::Detector::NPlusOneQuery.call_association(
282
+ proxy_association.owner,
283
+ proxy_association.reflection.name
284
+ )
281
285
  end
282
286
  super(column_name)
283
287
  end
@@ -294,6 +294,10 @@ module Bullet
294
294
  proxy_association.owner,
295
295
  proxy_association.reflection.name
296
296
  )
297
+ Bullet::Detector::NPlusOneQuery.call_association(
298
+ proxy_association.owner,
299
+ proxy_association.reflection.name
300
+ )
297
301
  end
298
302
  super(column_name)
299
303
  end
@@ -294,6 +294,10 @@ module Bullet
294
294
  proxy_association.owner,
295
295
  proxy_association.reflection.name
296
296
  )
297
+ Bullet::Detector::NPlusOneQuery.call_association(
298
+ proxy_association.owner,
299
+ proxy_association.reflection.name
300
+ )
297
301
  end
298
302
  super(column_name)
299
303
  end
@@ -9,12 +9,22 @@ class Object
9
9
  return if respond_to?(:persisted?) && !persisted?
10
10
 
11
11
  if self.class.respond_to?(:primary_keys) && self.class.primary_keys
12
- self.class.primary_keys.map { |primary_key| send primary_key }
13
- .join(',')
12
+ primary_key = self.class.primary_keys
14
13
  elsif self.class.respond_to?(:primary_key) && self.class.primary_key
15
- send self.class.primary_key
14
+ primary_key = self.class.primary_key
16
15
  else
17
- id
16
+ primary_key = :id
18
17
  end
18
+
19
+ bullet_join_potential_composite_primary_key(primary_key)
20
+ end
21
+
22
+ private
23
+
24
+ def bullet_join_potential_composite_primary_key(primary_keys)
25
+ return send(primary_keys) unless primary_keys.is_a?(Enumerable)
26
+
27
+ primary_keys.map { |primary_key| send primary_key }
28
+ .join(',')
19
29
  end
20
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bullet
4
- VERSION = '7.1.1'
4
+ VERSION = '7.1.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.1
4
+ version: 7.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-07 00:00:00.000000000 Z
11
+ date: 2023-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport