ar-ondemand 1.0.3 → 1.0.4

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGQxNGNjMTg4NzdkYjU2M2RiYTAyM2I3OTdiZDUyMzVjYTI3N2M5OQ==
4
+ MDYxMjI1MWU0YTFkNmI1YzBkYTY1NWI2OTY0OWM4YThiMmZjODhkMw==
5
5
  data.tar.gz: !binary |-
6
- Y2FjNGMzMjNjZDRiNjlmNDBjY2IxYWNkNTJjMDI0ODM1ODBhYTFhZQ==
6
+ M2JkMTFjZmExNWVhZDUyNzc0ODRhNDM5N2VlYjJlMGM2YmJkNzUwZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTRmYjk4ODgxYWEzNzNlZDk1ZGVlNDFmYzY1NGY5ODEyNTFlZTQxOTg1YWRm
10
- ZWI0MjkzYjg3NGU3ODc3Mzc3YzViNWM4YzgyZjM1NDMwMTkzNmI1NDYzZGEz
11
- ZTE4MmZmYzc0MmU3OTI0NTQ3ZmNhODM4MWM4MWM2ZTc3M2Q5NTQ=
9
+ OGJmYTJlZGI1N2UzOTUyYTUzMWNmOGJjYmZkYTMxYTUzNWYwMzM0NzFiNDUw
10
+ ODBhNzM5ODZmNWNhNWFkNzNiNTc5NzQyNTU3OTk2MmU3NTMyZTkwYzQzNWE1
11
+ NGRjNzg5Mzc3YTE1NjUwMmE4MWM5MzYzZWNkNjU5OTA0ZjcwYjc=
12
12
  data.tar.gz: !binary |-
13
- OGRlMTcyOWRiZGU3MjZiMWJiZjFmNTEzZGU1ZTRlZDFlOGQ4ZWQwZjI2MzVl
14
- YzlmMThhYzM5ODU4NzkwNTZiNDBmNjkxNDUxNmM2MDE4OWJmOTkwZmI0Mzhk
15
- NDA0N2JiYWU0MTNlMGQ1NGM4YmNkMGVhMWE0OGNiMGRjZGU2N2U=
13
+ NzY5NjMwZTA2NDU3ODZhZTY4ODg4MzkxYmJmMzlhZjc0ZTIxYWExYjlhYmFj
14
+ YzkyZTlmMTJkMDJjMTdlMjE1MTY0NTgwMmQ1OTc4MGNhMDA5YzgzZGM2MjFi
15
+ MDhmNTE5NDkxZTI5Yzc0MTM5NTJjZGRkOThkOWNjNGNlYTdmM2E=
@@ -14,7 +14,7 @@ module ActiveRecord
14
14
  end
15
15
 
16
16
  if (finder_options = options.except(:start, :batch_size)).present?
17
- raise "You can't specify an order, it's forced to be #{batch_order}" if options[:order].present?
17
+ raise "You can't specify an order, it's forced to be #{batch_order_delete_all_by_pk}" if options[:order].present?
18
18
  raise "You can't specify a limit, it's forced to be the batch_size" if options[:limit].present?
19
19
 
20
20
  relation = apply_finder_options(finder_options)
@@ -23,8 +23,8 @@ module ActiveRecord
23
23
  start = options.delete(:start)
24
24
  batch_size = options.delete(:batch_size)
25
25
 
26
- relation = relation.reorder(batch_order).limit(batch_size) if batch_size
27
- records = start ? query(relation.where(table[primary_key].gteq(start))) : query(relation)
26
+ relation = relation.reorder(batch_order_delete_all_by_pk).limit(batch_size) if batch_size
27
+ records = query_delete_all_by_pk(start ? relation.where(table[primary_key].gteq(start)) : relation)
28
28
 
29
29
  while records.any?
30
30
  records_size = records.size
@@ -34,18 +34,18 @@ module ActiveRecord
34
34
 
35
35
  break if batch_size.nil? || records_size < batch_size
36
36
 
37
- records = query relation.where(table[primary_key].gt(primary_key_offset))
37
+ records = query_delete_all_by_pk relation.where(table[primary_key].gt(primary_key_offset))
38
38
  end
39
39
  end
40
40
 
41
41
  private
42
42
 
43
- def query(ar)
43
+ def query_delete_all_by_pk(ar)
44
44
  results = ::ActiveRecord::Base.connection.exec_query ar.select([table[primary_key]]).to_sql
45
45
  results.rows.flatten
46
46
  end
47
47
 
48
- def batch_order
48
+ def batch_order_delete_all_by_pk
49
49
  "#{quoted_table_name}.#{quoted_primary_key} ASC"
50
50
  end
51
51
  end
@@ -18,7 +18,7 @@ module ActiveRecord
18
18
  end
19
19
 
20
20
  if (finder_options = options.except(:start, :batch_size)).present?
21
- raise "You can't specify an order, it's forced to be #{batch_order}" if options[:order].present?
21
+ raise "You can't specify an order, it's forced to be #{batch_order_for_reading}" if options[:order].present?
22
22
  raise "You can't specify a limit, it's forced to be the batch_size" if options[:limit].present?
23
23
 
24
24
  relation = apply_finder_options(finder_options)
@@ -27,8 +27,8 @@ module ActiveRecord
27
27
  start = options.delete(:start)
28
28
  batch_size = options.delete(:batch_size) || 1000
29
29
 
30
- relation = relation.reorder(batch_order).limit(batch_size)
31
- records = start ? query(relation.where(table[primary_key].gteq(start))) : query(relation)
30
+ relation = relation.reorder(batch_order_for_reading).limit(batch_size)
31
+ records = query_for_reading(start ? relation.where(table[primary_key].gteq(start)) : relation)
32
32
 
33
33
  while records.any?
34
34
  records_size = records.size
@@ -39,7 +39,7 @@ module ActiveRecord
39
39
  break if records_size < batch_size
40
40
 
41
41
  if primary_key_offset
42
- records = query relation.where(table[primary_key].gt(primary_key_offset))
42
+ records = query_for_reading relation.where(table[primary_key].gt(primary_key_offset))
43
43
  else
44
44
  raise "Primary key not included in the custom select clause"
45
45
  end
@@ -48,12 +48,12 @@ module ActiveRecord
48
48
 
49
49
  private
50
50
 
51
- def query(ar)
51
+ def query_for_reading(ar)
52
52
  results = ::ActiveRecord::Base.connection.exec_query ar.to_sql
53
53
  ::ActiveRecord::OnDemand::ResultSet.new self.arel.engine, results
54
54
  end
55
55
 
56
- def batch_order
56
+ def batch_order_for_reading
57
57
  "#{quoted_table_name}.#{quoted_primary_key} ASC"
58
58
  end
59
59
  end
@@ -1,3 +1,3 @@
1
1
  module ArOnDemand
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar-ondemand
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Frank