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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c3286a31a994b2afe81cefe35abf494e8edb02ce52fb231d63ca8381e3dba01
|
4
|
+
data.tar.gz: e61a7565407ddccb61e60f89094afe634ef1d02b965969396e43f1a43d21627c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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
|
data/lib/occams-record/merge.rb
CHANGED
@@ -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
|
-
|
39
|
+
begin
|
40
40
|
id = assoc_row.send assoc_attr
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
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)
|
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.
|
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-
|
11
|
+
date: 2019-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|