occams-record 1.0.2 → 1.0.3

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: 362412629f1efd7e076409b017c925d112df61a26fda25f9dc4a6f318d250dc7
4
- data.tar.gz: fc0a8b2e652ded15b47e85759e6a927e35f0feda6adc7792d0b05364e0343826
3
+ metadata.gz: 0c3286a31a994b2afe81cefe35abf494e8edb02ce52fb231d63ca8381e3dba01
4
+ data.tar.gz: e61a7565407ddccb61e60f89094afe634ef1d02b965969396e43f1a43d21627c
5
5
  SHA512:
6
- metadata.gz: 570685d5cfef170c128a0c759c48c2e045991fccf0a1be0ecfc9f5cdc9f5ce1078594af2d895d0c68170aab4e6240fba593c5a5c38a3b43b7eb2478694691c25
7
- data.tar.gz: 4d2076f93a517969f2eb21142eb5455d0376dc4d9e57526dcde1919bd16acc36772becf4b7bac25b8628e4aa4c908073dbcd37cafe0542df90291403e21b64a7
6
+ metadata.gz: acfaec212fea40cf693f276165c649de408ab5a6d6aabfa47ff996a94daaf09fec651d6f2eb9e03168da29df1c9a4bdec572d4aca55506b1f5058e3b175fa3bd
7
+ data.tar.gz: db1a088f0e15dd813034a2b1a97490de7d8b4d81a1aa5e949572c20180e2fd3ad52746d1edad02c56ddbe1b0eb3c90c9966cc3ba8d1dcc9d29a7248036ad4919
@@ -55,7 +55,7 @@ module OccamsRecord
55
55
  next if type.nil? or type == ""
56
56
  model = type.constantize
57
57
  ids = rows_of_type.map(&@foreign_key).uniq
58
- q = base_scope(model).where(model.primary_key => ids)
58
+ q = base_scope(model).where(@ref.active_record_primary_key => ids)
59
59
  yield q if ids.any?
60
60
  end
61
61
  end
@@ -36,11 +36,11 @@ module OccamsRecord
36
36
  if mapping.size == 1
37
37
  target_attr, assoc_attr = target_attrs[0], assoc_attrs[0]
38
38
  assoc_rows_by_ids = assoc_rows.reduce({}) { |a, assoc_row|
39
- #begin
39
+ begin
40
40
  id = assoc_row.send assoc_attr
41
- #rescue NoMethodError => e
42
- # raise MissingColumnError.new(assoc_row, e.name)
43
- #end
41
+ rescue NoMethodError => e
42
+ raise MissingColumnError.new(assoc_row, e.name)
43
+ end
44
44
  a[id] ||= assoc_row
45
45
  a
46
46
  }
@@ -26,7 +26,9 @@ module OccamsRecord
26
26
  self.associations = association_names.map(&:to_s)
27
27
  self.model_name = model ? model.name : nil
28
28
  self.table_name = model ? model.table_name : nil
29
- self.primary_key = model&.primary_key&.to_s
29
+ self.primary_key = if model&.primary_key and (pkey = model.primary_key.to_s) and columns.include?(pkey)
30
+ pkey
31
+ end
30
32
 
31
33
  # Build getters & setters for associations. (We need setters b/c they're set AFTER the row is initialized
32
34
  attr_accessor(*association_names)
@@ -3,5 +3,5 @@
3
3
  #
4
4
  module OccamsRecord
5
5
  # Library version
6
- VERSION = '1.0.2'.freeze
6
+ VERSION = '1.0.3'.freeze
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: occams-record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Hollinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-28 00:00:00.000000000 Z
11
+ date: 2019-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord