occams-record 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/occams-record/eager_loaders/belongs_to.rb +1 -1
- data/lib/occams-record/results/row.rb +1 -1
- data/lib/occams-record/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f20725f84205589f6d7f9f11b54870e7cdc4697020863133e8669f80ef9c601d
|
4
|
+
data.tar.gz: 3abfc4b311d439d866ff40c512f8a7ce478c0f938483fb6805dad1a1ac4c1ebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03272f59314447452b174e24c0e8b334fbd9ce0a03ef29b54d353710b29f08b679a8d3b8e5e6108593a10019a84a7069519810e37c7598e79d3002f7314f7ede
|
7
|
+
data.tar.gz: e9b99f0ef4e60c0ac1e70d431dc40ac9e2f0d265e4687eba9dbf8163ce89894baca4b50c2e34b3e8cecbc99727800039b404eedb0e156a2b887b5e9736d20780
|
data/README.md
CHANGED
@@ -12,14 +12,14 @@ OccamsRecord is a high-efficiency, advanced query library for use alongside Acti
|
|
12
12
|
|
13
13
|
### 2) Supercharged querying & eager loading
|
14
14
|
|
15
|
-
Continue using ActiveRecord's query builder, but let Occams take over eager loading and raw SQL calls. None of the examples below are possible with ActiveRecord, but OccamsRecord
|
15
|
+
Continue using ActiveRecord's query builder, but let Occams take over running them, eager loading, and raw SQL calls. None of the examples below are possible with ActiveRecord, but OccamsRecord makes them trivial. (More complete examples are shown later, but these should whet your appetite.)
|
16
16
|
|
17
17
|
**Customize the SQL used to eager load associations**
|
18
18
|
|
19
19
|
```ruby
|
20
20
|
OccamsRecord.
|
21
21
|
query(User.active).
|
22
|
-
eager_load(:orders, ->(q) { q.where("created_at >= ?", date })
|
22
|
+
eager_load(:orders, ->(q) { q.where("created_at >= ?", date).order("created_at DESC") })
|
23
23
|
```
|
24
24
|
|
25
25
|
**Use `ORDER BY` with `find_each`/`find_in_batches`**
|
@@ -34,7 +34,7 @@ module OccamsRecord
|
|
34
34
|
#
|
35
35
|
def merge!(assoc_rows, rows)
|
36
36
|
Merge.new(rows, name).
|
37
|
-
single!(assoc_rows, {@ref.foreign_key.to_s => @ref.
|
37
|
+
single!(assoc_rows, {@ref.foreign_key.to_s => @ref.association_primary_key.to_s})
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -152,7 +152,7 @@ module OccamsRecord
|
|
152
152
|
def define_ids_reader!(assoc)
|
153
153
|
model = self.class._model
|
154
154
|
ref = model.reflections[assoc]
|
155
|
-
pkey = ref.
|
155
|
+
pkey = ref.klass.primary_key.to_sym
|
156
156
|
|
157
157
|
self.class.class_eval do
|
158
158
|
define_method "#{assoc.singularize}_ids" do
|
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.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|