occams-record 0.26.0 → 0.27.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 +5 -5
- data/README.md +1 -1
- data/lib/occams-record/eager_loaders/ad_hoc_base.rb +8 -4
- data/lib/occams-record/eager_loaders/base.rb +1 -2
- data/lib/occams-record/eager_loaders/habtm.rb +1 -1
- data/lib/occams-record/eager_loaders/has_one.rb +1 -1
- data/lib/occams-record/results.rb +3 -0
- data/lib/occams-record/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9c718e8ed411d6d2a139dcc27c2c0f7fa788fc6dafb8c534d3332682c85502f6
|
4
|
+
data.tar.gz: 464d6e322e1a478f861cb576b4e506589da318485c29fe5ec852726fcba2a692
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed85408318c87e662a14cc863fe43cb2b2e1f1a5aae739ff1a1b22968957a455e771e3ac6fcb3b902b0febe9585bddad6b4c02640bfaa077a6e6a98f3a3c148d
|
7
|
+
data.tar.gz: 78f981128bd9fad0d6a670ed21426366cf3ac1b74169f3571a6335ae9cf1d5a5c2c790fa7f4bc1c09d4b5756a0a7850998467a779c7bef4db2dc50b1553fb330
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Occam's Record is a high-efficiency, advanced query library for ActiveRecord app
|
|
7
7
|
* 3x-5x faster than ActiveRecord queries.
|
8
8
|
* Uses 1/3 the memory of ActiveRecord query results.
|
9
9
|
* Eliminates the N+1 query problem.
|
10
|
-
*
|
10
|
+
* Customize the SQL when eager loading associations.
|
11
11
|
* `find_each`/`find_in_batches` respects `order` and `limit`.
|
12
12
|
* Allows eager loading of associations when querying with raw SQL.
|
13
13
|
* Allows `find_each`/`find_in_batches` when querying with raw SQL.
|
@@ -34,9 +34,13 @@ module OccamsRecord
|
|
34
34
|
#
|
35
35
|
def run(rows, query_logger: nil)
|
36
36
|
calc_ids(rows) { |ids|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
assoc = if ids.any?
|
38
|
+
binds = @binds.merge({:ids => ids})
|
39
|
+
RawQuery.new(@sql, binds, use: @use, query_logger: query_logger, &@eval_block).model(@model).run
|
40
|
+
else
|
41
|
+
[]
|
42
|
+
end
|
43
|
+
merge! assoc, rows
|
40
44
|
}
|
41
45
|
end
|
42
46
|
|
@@ -56,7 +60,7 @@ module OccamsRecord
|
|
56
60
|
raise MissingColumnError.new(row, e.name)
|
57
61
|
end
|
58
62
|
}.compact.uniq
|
59
|
-
yield ids
|
63
|
+
yield ids
|
60
64
|
end
|
61
65
|
|
62
66
|
def merge!(assoc_rows, rows)
|
@@ -29,8 +29,7 @@ module OccamsRecord
|
|
29
29
|
#
|
30
30
|
def run(rows, query_logger: nil)
|
31
31
|
query(rows) { |*args|
|
32
|
-
|
33
|
-
assoc_rows = Query.new(scope, use: @use, query_logger: query_logger, &@eval_block).run
|
32
|
+
assoc_rows = args[0] ? Query.new(args[0], use: @use, query_logger: query_logger, &@eval_block).run : []
|
34
33
|
merge! assoc_rows, rows, *args[1..-1]
|
35
34
|
}
|
36
35
|
end
|
@@ -13,7 +13,7 @@ module OccamsRecord
|
|
13
13
|
def query(rows)
|
14
14
|
join_rows = fetch_join_rows(rows)
|
15
15
|
assoc_ids = join_rows.map { |row| row[1] }.compact.uniq
|
16
|
-
yield base_scope.where(@ref.association_primary_key => assoc_ids), join_rows
|
16
|
+
yield assoc_ids.any? ? base_scope.where(@ref.association_primary_key => assoc_ids) : nil, join_rows
|
17
17
|
end
|
18
18
|
|
19
19
|
#
|
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.27.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: 2018-04-
|
11
|
+
date: 2018-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
78
|
rubyforge_project:
|
79
|
-
rubygems_version: 2.
|
79
|
+
rubygems_version: 2.7.3
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: The missing high-efficiency query API for ActiveRecord
|