composite_primary_keys 10.0.4 → 10.0.5

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: 89c1bd9183cbf26dfed31a862493f5760bd3e1892f3c8b39bed62b2605d4b241
4
- data.tar.gz: 0c2e627e3e9b7b9fc27410967f400496c2fc5cc90c81c20528374ee4024033ea
3
+ metadata.gz: f506d34f44d88354550c10d7b79f38c206dfa739c9c903e59c888252db3ae9ed
4
+ data.tar.gz: 06e5788af10e07e0dbe785338aa35c8cce99df310a7e43d3605b1cefb0eaa0ac
5
5
  SHA512:
6
- metadata.gz: d1c56f5c4ce9c03c604d3d8b3df31ea4c8d652cd310d15af11ed3cd6d72c9b44c9fcb12065ba0ba225ddd918fa9655d75bb1e5fabf5b4923de2a0c8535ecca3e
7
- data.tar.gz: ad9c9d9a3b5df644fa5accc5b2cb9db0465b9254a26912f4cc66ba76a0e44666df1c47cc00a87b891fbdfce1f8bbc516ba05043f3d59fb1e51f82a37e527ef21
6
+ metadata.gz: 83ec3b8f8f42e7a5c92f11c60cb86fdb8fd4bdc9e6a58f1f3305ffb5c9b6af9b2abaabcaa43eeaa2e40e19cddab4cad5d7e5501905643e7b4fad0749525ac0b7
7
+ data.tar.gz: d1a8bad2cdea8ff1eab3ba7d5c456d68f008583b26b6000a930f58d319842aa6b2a24e66d7d509bd531cce4852f062797b96e53c0f929ed8aa0c6a19d40621c2
@@ -1,3 +1,6 @@
1
+ == 10.0.5 (2018-06-24)
2
+ * Fix in_batches (Urmo Rae)
3
+
1
4
  == 10.0.4 (2018-06-17)
2
5
 
3
6
  * Lock mysql2 gem to 0.4.x (Le Trung Kien)
@@ -25,6 +28,10 @@
25
28
  * Fix typo in Readme (Mike Gunderloy)
26
29
  * Improved sql server support (Artyom Nikolaev)
27
30
 
31
+ == 9.0.10 (2018-06-24)
32
+
33
+ * Fix AR 5.0.7 (Jordan Owens)
34
+
28
35
  == 9.0.8 (2017-10-11)
29
36
 
30
37
  * Fix Paper Trail compatibility (Sean Linsley)
@@ -7,11 +7,17 @@ module CompositePrimaryKeys
7
7
  return BatchEnumerator.new(of: of, start: start, finish: finish, relation: self)
8
8
  end
9
9
 
10
- if arel.orders.present? || arel.taken.present?
11
- act_on_order_or_limit_ignored(error_on_ignore)
10
+ if arel.orders.present?
11
+ act_on_ignored_order(error_on_ignore)
12
12
  end
13
13
 
14
- relation = relation.reorder(batch_order).limit(of)
14
+ batch_limit = of
15
+ if limit_value
16
+ remaining = limit_value
17
+ batch_limit = remaining if remaining < batch_limit
18
+ end
19
+
20
+ relation = relation.reorder(batch_order).limit(batch_limit)
15
21
  relation = apply_limits(relation, start, finish)
16
22
  batch_relation = relation
17
23
 
@@ -39,9 +45,22 @@ module CompositePrimaryKeys
39
45
 
40
46
  yield yielded_relation
41
47
 
42
- break if ids.length < of
48
+ break if ids.length < batch_limit
49
+
50
+ if limit_value
51
+ remaining -= ids.length
52
+
53
+ if remaining == 0
54
+ # Saves a useless iteration when the limit is a multiple of the
55
+ # batch size.
56
+ break
57
+ elsif remaining < batch_limit
58
+ relation = relation.limit(remaining)
59
+ end
60
+ end
61
+
43
62
  # CPK
44
- # batch_relation = relation.where(arel_attribute(primary_key).gt(primary_key_offset))
63
+ batch_relation = relation.where(arel_attribute(primary_key).gt(primary_key_offset))
45
64
  batch_relation = if composite?
46
65
  # CPK
47
66
  # Lexicographically select records
@@ -2,7 +2,7 @@ module CompositePrimaryKeys
2
2
  module VERSION
3
3
  MAJOR = 10
4
4
  MINOR = 0
5
- TINY = 4
5
+ TINY = 5
6
6
  STRING = [MAJOR, MINOR, TINY].join('.')
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composite_primary_keys
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.4
4
+ version: 10.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charlie Savage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-17 00:00:00.000000000 Z
11
+ date: 2018-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord