occams-record 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -1
- data/lib/occams-record/eager_loaders/habtm.rb +4 -4
- data/lib/occams-record/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 626b915405cadac96171e3283e1f05172ff5a272
|
4
|
+
data.tar.gz: bb347409b11e0c9602520a2444b56bb751c1f0e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 480de46340d39119a7e2b9b2734db2ac204d938e4313eef0b50d3ea39fb575683c84c78455a4f9492891f36074acdf611d634702f3d1d353df1722e60f75ed11
|
7
|
+
data.tar.gz: 5ddc0ad13f4d214e921341e88428e2e40bfac204f6e377343110ac7ca875ac668722361261f7d35cc9cfa2f3fb70465082725db118c02467086d339727210b08
|
data/README.md
CHANGED
@@ -82,7 +82,7 @@ widgets = OccamsRecord.
|
|
82
82
|
eager_load(:order_items, select: "widget_id, order_id") {
|
83
83
|
|
84
84
|
# load the orders
|
85
|
-
eager_load(:orders, -> {
|
85
|
+
eager_load(:orders, -> { select("id, customer_id").order("order_date DESC") }) {
|
86
86
|
|
87
87
|
# load the customers who made the orders, but only their names
|
88
88
|
eager_load(:customer, select: "id, name")
|
@@ -130,6 +130,13 @@ widgets[0].orders[0].description
|
|
130
130
|
=> "O839SJZ98B 1/8/2017"
|
131
131
|
```
|
132
132
|
|
133
|
+
## Unsupported features
|
134
|
+
|
135
|
+
The following `ActiveRecord` are not supported, and I have no plans to do so. However, I'd be glad to accept pull requests.
|
136
|
+
|
137
|
+
* ActiveRecord enum types
|
138
|
+
* ActiveRecord serialized types
|
139
|
+
|
133
140
|
## Testing
|
134
141
|
|
135
142
|
To run the tests, simply run:
|
@@ -20,20 +20,20 @@ module OccamsRecord
|
|
20
20
|
#
|
21
21
|
def merge!(assoc_rows, rows)
|
22
22
|
joins_by_id = join_rows(rows).reduce({}) { |a, join|
|
23
|
-
id = join[0]
|
23
|
+
id = join[0].to_s
|
24
24
|
a[id] ||= []
|
25
|
-
a[id] << join[1]
|
25
|
+
a[id] << join[1].to_s
|
26
26
|
a
|
27
27
|
}
|
28
28
|
|
29
29
|
assoc_rows_by_id = assoc_rows.reduce({}) { |a, row|
|
30
|
-
id = row.send
|
30
|
+
id = row.send(@ref.association_primary_key).to_s
|
31
31
|
a[id] = row
|
32
32
|
a
|
33
33
|
}
|
34
34
|
|
35
35
|
rows.each do |row|
|
36
|
-
id = row.send
|
36
|
+
id = row.send(@ref.active_record_primary_key).to_s
|
37
37
|
assoc_fkeys = (joins_by_id[id] || []).uniq
|
38
38
|
associations = assoc_rows_by_id.values_at(*assoc_fkeys).compact.uniq
|
39
39
|
row.send @assign, associations
|
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: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|