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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 707ed6c9bf173cd193bb01d26149eb78acc2908e352af3eb863c483c357e6a5e
4
- data.tar.gz: 257c5d00ececf487537d599103d1f60b9adede4e1411e1e82f0c66e01210bfb2
3
+ metadata.gz: '0338de44620fd361fbf185253f3c28dbf3cd6fe6e12b58724da27ec7cbcca78a'
4
+ data.tar.gz: 36689a595b7272d2f9fceb647a4e303ffd776ea323f378f7b2a0c3b006f139d0
5
5
  SHA512:
6
- metadata.gz: ac390d24a51ed24ba8cf941bae278bf0756c55724fd1b17f496b56ad11aae74873677cc698c78d44bb39a976e241a42c3f2879df8b29d6125ade39eed9ed83df
7
- data.tar.gz: c416b257ff7d5d95aea4bb195b56009e912fd93d4127d77fc68c2d3d5ca28ed6e84f99b1a959410cb39a7273927394bb10eba6a97dffa116af74a75b9078b8b2
6
+ metadata.gz: 8b261d5db1d3c75f3a6ed7018d2c82efc85353908db883a35deb47cb0ff6f457d610b295a5e6c09533d6b5fc41e815ae0ce51fc43c5f5d3bbf40e90798236631
7
+ data.tar.gz: e7b18444881fc1fba960082caa64f256e762977010afe679e30698dba9876d69f3779f0fd0e4b9ed3f5c5819830e70de4f908cdeed6a67a0fa4c2b4b4b53f47b
@@ -29,12 +29,14 @@ module OccamsRecord
29
29
  a
30
30
  }
31
31
 
32
- assoc_rows_by_id = assoc_rows.reduce({}) { |a, row|
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
@@ -3,5 +3,5 @@
3
3
  #
4
4
  module OccamsRecord
5
5
  # Library version
6
- VERSION = '0.24.0'.freeze
6
+ VERSION = '0.25.0'.freeze
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: occams-record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Hollinger