occams-record 0.24.0 → 0.25.0
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 +4 -4
- data/lib/occams-record/eager_loaders/habtm.rb +6 -2
- data/lib/occams-record/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0338de44620fd361fbf185253f3c28dbf3cd6fe6e12b58724da27ec7cbcca78a'
|
4
|
+
data.tar.gz: 36689a595b7272d2f9fceb647a4e303ffd776ea323f378f7b2a0c3b006f139d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b261d5db1d3c75f3a6ed7018d2c82efc85353908db883a35deb47cb0ff6f457d610b295a5e6c09533d6b5fc41e815ae0ce51fc43c5f5d3bbf40e90798236631
|
7
|
+
data.tar.gz: e7b18444881fc1fba960082caa64f256e762977010afe679e30698dba9876d69f3779f0fd0e4b9ed3f5c5819830e70de4f908cdeed6a67a0fa4c2b4b4b53f47b
|
@@ -29,12 +29,14 @@ module OccamsRecord
|
|
29
29
|
a
|
30
30
|
}
|
31
31
|
|
32
|
-
|
32
|
+
assoc_order_cache = {} # maintains the original order of assoc_rows
|
33
|
+
assoc_rows_by_id = assoc_rows.each_with_index.reduce({}) { |a, (row, idx)|
|
33
34
|
begin
|
34
35
|
id = row.send(@ref.association_primary_key).to_s
|
35
36
|
rescue NoMethodError => e
|
36
37
|
raise MissingColumnError.new(row, e.name)
|
37
38
|
end
|
39
|
+
assoc_order_cache[id] = idx
|
38
40
|
a[id] = row
|
39
41
|
a
|
40
42
|
}
|
@@ -46,7 +48,9 @@ module OccamsRecord
|
|
46
48
|
rescue NoMethodError => e
|
47
49
|
raise MissingColumnError.new(row, e.name)
|
48
50
|
end
|
49
|
-
assoc_fkeys = (joins_by_id[id] || []).uniq
|
51
|
+
assoc_fkeys = (joins_by_id[id] || []).uniq.
|
52
|
+
sort_by { |fkey| assoc_order_cache[fkey] || 0 }
|
53
|
+
|
50
54
|
associations = assoc_rows_by_id.values_at(*assoc_fkeys).compact.uniq
|
51
55
|
row.send assign, associations
|
52
56
|
end
|