goldiloader 0.0.9 → 2.1.2

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.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goldiloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Turkel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-14 00:00:00.000000000 Z
11
+ date: 2018-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,40 +16,54 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '4.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '4.3'
22
+ version: '5.3'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '3.2'
29
+ version: '4.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '4.3'
32
+ version: '5.3'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activesupport
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '3.2'
39
+ version: '4.2'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '4.3'
42
+ version: '5.3'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '3.2'
49
+ version: '4.2'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '4.3'
52
+ version: '5.3'
53
+ - !ruby/object:Gem::Dependency
54
+ name: appraisal
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
53
67
  - !ruby/object:Gem::Dependency
54
68
  name: coveralls
55
69
  requirement: !ruby/object:Gem::Requirement
@@ -98,28 +112,42 @@ dependencies:
98
112
  requirements:
99
113
  - - "~>"
100
114
  - !ruby/object:Gem::Version
101
- version: '2'
115
+ version: '3'
102
116
  type: :development
103
117
  prerelease: false
104
118
  version_requirements: !ruby/object:Gem::Requirement
105
119
  requirements:
106
120
  - - "~>"
107
121
  - !ruby/object:Gem::Version
108
- version: '2'
122
+ version: '3'
109
123
  - !ruby/object:Gem::Dependency
110
124
  name: simplecov
111
125
  requirement: !ruby/object:Gem::Requirement
112
126
  requirements:
113
- - - "~>"
127
+ - - ">="
114
128
  - !ruby/object:Gem::Version
115
- version: 0.7.1
129
+ version: '0'
116
130
  type: :development
117
131
  prerelease: false
118
132
  version_requirements: !ruby/object:Gem::Requirement
119
133
  requirements:
120
- - - "~>"
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ - !ruby/object:Gem::Dependency
138
+ name: mime-types
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
121
149
  - !ruby/object:Gem::Version
122
- version: 0.7.1
150
+ version: '0'
123
151
  - !ruby/object:Gem::Dependency
124
152
  name: sqlite3
125
153
  requirement: !ruby/object:Gem::Requirement
@@ -141,15 +169,7 @@ executables: []
141
169
  extensions: []
142
170
  extra_rdoc_files: []
143
171
  files:
144
- - ".gitignore"
145
- - ".rspec"
146
- - ".travis.yml"
147
- - CHANGELOG.md
148
- - Gemfile
149
172
  - LICENSE.txt
150
- - README.md
151
- - Rakefile
152
- - goldiloader.gemspec
153
173
  - lib/goldiloader.rb
154
174
  - lib/goldiloader/active_record_patches.rb
155
175
  - lib/goldiloader/association_info.rb
@@ -158,15 +178,14 @@ files:
158
178
  - lib/goldiloader/auto_include_context.rb
159
179
  - lib/goldiloader/compatibility.rb
160
180
  - lib/goldiloader/version.rb
161
- - spec/db/database.yml
162
- - spec/db/schema.rb
163
- - spec/goldiloader/auto_include_context_spec.rb
164
- - spec/goldiloader/goldiloader_spec.rb
165
- - spec/spec_helper.rb
166
181
  homepage: https://github.com/salsify/goldiloader
167
182
  licenses:
168
183
  - MIT
169
- metadata: {}
184
+ metadata:
185
+ homepage_uri: https://github.com/salsify/goldiloader
186
+ changelog_uri: https://github.com/salsify/goldiloader/blob/master/CHANGELOG.md
187
+ source_code_uri: https://github.com/salsify/goldiloader/
188
+ bug_tracker_uri: https://github.com/salsify/goldiloader/issues
170
189
  post_install_message:
171
190
  rdoc_options: []
172
191
  require_paths:
@@ -175,7 +194,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
175
194
  requirements:
176
195
  - - ">="
177
196
  - !ruby/object:Gem::Version
178
- version: '0'
197
+ version: '2.1'
179
198
  required_rubygems_version: !ruby/object:Gem::Requirement
180
199
  requirements:
181
200
  - - ">="
@@ -183,13 +202,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
202
  version: '0'
184
203
  requirements: []
185
204
  rubyforge_project:
186
- rubygems_version: 2.4.6
205
+ rubygems_version: 2.6.14
187
206
  signing_key:
188
207
  specification_version: 4
189
208
  summary: Automatic Rails association eager loading
190
- test_files:
191
- - spec/db/database.yml
192
- - spec/db/schema.rb
193
- - spec/goldiloader/auto_include_context_spec.rb
194
- - spec/goldiloader/goldiloader_spec.rb
195
- - spec/spec_helper.rb
209
+ test_files: []
data/.gitignore DELETED
@@ -1,20 +0,0 @@
1
- *.gem
2
- *.iml
3
- *.rbc
4
- .bundle
5
- .config
6
- .idea/
7
- .yardoc
8
- Gemfile.lock
9
- InstalledFiles
10
- _yardoc
11
- coverage
12
- doc/
13
- lib/bundler/man
14
- log/
15
- pkg
16
- rdoc
17
- spec/reports
18
- test/tmp
19
- test/version_tmp
20
- tmp
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format progress
data/.travis.yml DELETED
@@ -1,20 +0,0 @@
1
- language: ruby
2
- env:
3
- - RAILS_VERSION="~> 3.2.21" JRUBY_OPTS="$JRUBY_OPTS --debug"
4
- - RAILS_VERSION="~> 4.0.13" JRUBY_OPTS="$JRUBY_OPTS --debug"
5
- - RAILS_VERSION="~> 4.1.9" JRUBY_OPTS="$JRUBY_OPTS --debug"
6
- - RAILS_VERSION="~> 4.2.0" JRUBY_OPTS="$JRUBY_OPTS --debug"
7
- rvm:
8
- - 1.9.3
9
- - 2.0.0
10
- - 2.1.0
11
- - 2.2.0
12
- - jruby-19mode
13
- matrix:
14
- exclude:
15
- # See https://github.com/salsify/goldiloader/issues/22
16
- - rvm: jruby-19mode
17
- env: RAILS_VERSION="~> 4.2.0" JRUBY_OPTS="$JRUBY_OPTS --debug"
18
- # See https://github.com/rails/rails/pull/18306
19
- - rvm: 2.2.0
20
- env: RAILS_VERSION="~> 3.2.21" JRUBY_OPTS="$JRUBY_OPTS --debug"
data/CHANGELOG.md DELETED
@@ -1,51 +0,0 @@
1
- # Changelog
2
-
3
- ### 0.0.9
4
- * Merge [pull request](https://github.com/salsify/goldiloader/pull/24) - Optimization: Cache compatibility
5
- checks. **Thanks Jonathan Calvert!**
6
-
7
- ### 0.0.8
8
- * Fix [issue 23](https://github.com/salsify/goldiloader/issues/23) - Handle polymorphic belongs_to
9
- associations in Rails 4 that have a mix of non-nil and nil values.
10
-
11
- ### 0.0.7
12
- * Fix [issue 20](https://github.com/salsify/goldiloader/issues/20) by not auto-eager loading
13
- associations that are instance dependent. Eager loading these associations produces potentially
14
- incorrect results and leads to a deprecation warning in Rails 4.2.
15
- * Fix [issue 21](https://github.com/salsify/goldiloader/issues/21) - Handle explicit eager loads
16
- of singular associations that are nil.
17
- * Rails 4.2 support.
18
-
19
- ### 0.0.6
20
- * Workaround [issue 16](https://github.com/salsify/goldiloader/issues/16) by not auto-eager loading
21
- has_and_belongs_to_many associations with a uniq in Rails 3.2 since Rails doesn't eager load them
22
- properly.
23
- * Fix [issue 17](https://github.com/salsify/goldiloader/issues/17) - models eager loaded via an explicit
24
- call to eager_load now auto eager load nested models.
25
-
26
- ### 0.0.5
27
-
28
- * Fix ActiveRecord and ActiveSupport dependencies to work with versions greater than 4.1.0. Thanks for the pull
29
- requests [Alexey Volodkin](https://github.com/miraks) and [Philip Claren](https://github.com/DerKobe).
30
- * Workaround [issue 13](https://github.com/salsify/goldiloader/issues/13) by not auto-eager loading associations
31
- that use `unscope`. This workaround will be removed when the underlying
32
- [bug 11036](https://github.com/rails/rails/issues/11036) in the Rails eager loader is fixed.
33
- * Workaround [issue 11](https://github.com/salsify/goldiloader/issues/11) by not auto-eager loading associations
34
- that use `joins`. This workaround will be removed when the underlying
35
- [bug 11518](https://github.com/rails/rails/pull/11518) in the Rails eager loader is fixed.
36
- * Fix [issue 15](https://github.com/salsify/goldiloader/issues/15) - Don't auto eager load associations
37
- with finder_sql in Rails 4.0. Previously this was only done for Rails 3.2.
38
-
39
- ### 0.0.4
40
-
41
- * Fix [issue 3](https://github.com/salsify/goldiloader/issues/3) - `exists?` method should take an argument.
42
- Thanks for reporting [Bert Goethals](https://github.com/Bertg)
43
- * Fix [issue 4](https://github.com/salsify/goldiloader/issues/4) - Associations couldn't be loaded in after
44
- destroy callbacks. Thanks for reporting [Bert Goethals](https://github.com/Bertg)
45
- * Fix [issue 6](https://github.com/salsify/goldiloader/issues/6) - Models in read only associations weren't
46
- being marked as read only
47
- * Fix [issue 7](https://github.com/salsify/goldiloader/issues/7) - Don't attempt to eager load associations that
48
- aren't eager loadable e.g. if they have a limit
49
- * Fix [issue 8](https://github.com/salsify/goldiloader/issues/8) - Handle eager loading associations whose
50
- accessor methods have been overridden.
51
-
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
data/README.md DELETED
@@ -1,187 +0,0 @@
1
- # Goldiloader
2
-
3
- [![Gem Version](https://badge.fury.io/rb/goldiloader.png)][gem]
4
- [![Build Status](https://secure.travis-ci.org/salsify/goldiloader.png?branch=master)][travis]
5
- [![Code Climate](https://codeclimate.com/github/salsify/goldiloader.png)][codeclimate]
6
- [![Coverage Status](https://coveralls.io/repos/salsify/goldiloader/badge.png)][coveralls]
7
-
8
- [gem]: https://rubygems.org/gems/goldiloader
9
- [travis]: http://travis-ci.org/salsify/goldiloader
10
- [codeclimate]: https://codeclimate.com/github/salsify/goldiloader
11
- [coveralls]: https://coveralls.io/r/salsify/goldiloader
12
-
13
- Wouldn't it be awesome if ActiveRecord didn't make you think about eager loading and it just did the "right" thing by default? With Goldiloader it can!
14
-
15
- Consider the following models:
16
-
17
- ```
18
- class Blog < ActiveRecord::Base
19
- has_many :posts
20
- end
21
-
22
- class Post < ActiveRecord::Base
23
- belongs_to :blog
24
- end
25
- ```
26
-
27
- Here are some sample queries without the Goldiloader:
28
-
29
- ```
30
- > blogs = Blogs.limit(5).to_a
31
- # SELECT * FROM blogs LIMIT 5
32
-
33
- > blogs.each { |blog| blog.posts.to_a }
34
- # SELECT * FROM posts WHERE blog_id = 1
35
- # SELECT * FROM posts WHERE blog_id = 2
36
- # SELECT * FROM posts WHERE blog_id = 3
37
- # SELECT * FROM posts WHERE blog_id = 4
38
- # SELECT * FROM posts WHERE blog_id = 5
39
- ```
40
-
41
- Here are the same queries with the Goldiloader:
42
-
43
- ```
44
- > blogs = Blogs.limit(5).to_a
45
- # SELECT * FROM blogs LIMIT 5
46
-
47
- > blogs.each { |blog| blog.posts.to_a }
48
- # SELECT * FROM posts WHERE blog_id IN (1,2,3,4,5)
49
- ```
50
-
51
- Whoa! It automatically loaded all of the posts for our five blogs in a single database query without specifying any eager loads! Goldiloader assumes that you'll access all models loaded from a query in a uniform way. The first time you traverse an association on any of the models it will eager load the association for all the models. It even works with arbitrary nesting of associations.
52
-
53
- Read more about the motivation for the Goldiloader in this [blog post](http://www.salsify.com/blog/automatic-eager-loading-rails/).
54
-
55
- ## Installation
56
-
57
- Add this line to your application's Gemfile:
58
-
59
- gem 'goldiloader'
60
-
61
- And then execute:
62
-
63
- $ bundle
64
-
65
- Or install it yourself as:
66
-
67
- $ gem install goldiloader
68
-
69
- ## Usage
70
-
71
- By default all associations will be automatically eager loaded when they are first accessed so hopefully most use cases should require no additional configuration. Note you're still free to explicitly eager load associations via `eager_load`, `includes`, or `preload`.
72
-
73
- ### Association Options
74
-
75
- Goldiloader supports a few options on ActiveRecord associations to customize its behavior.
76
-
77
- #### auto_include
78
-
79
- You can disable automatic eager loading on specific associations with the `auto_include` option:
80
-
81
- ```
82
- class Blog < ActiveRecord::Base
83
- has_many :posts, auto_include: false
84
- end
85
- ```
86
-
87
- #### fully_load
88
-
89
- There are several association methods that ActiveRecord can either execute on in memory models or push down into SQL depending on whether or not the association is loaded. This includes the following methods:
90
-
91
- * `first`
92
- * `second`
93
- * `third`
94
- * `fourth`
95
- * `fifth`
96
- * `forty_two` (one of the hidden gems in Rails 4.1)
97
- * `last`
98
- * `size`
99
- * `ids_reader`
100
- * `empty?`
101
- * `exists?`
102
-
103
- This can cause problems for certain usage patterns if we're no longer specifying eager loads:
104
-
105
- ```
106
- > blogs = Blogs.limit(5).to_a
107
- # SELECT * FROM blogs LIMIT 5
108
-
109
- > blogs.each do |blog|
110
- if blog.posts.exists?
111
- puts blog.posts
112
- else
113
- puts 'No posts'
114
- end
115
- # SELECT 1 AS one FROM posts WHERE blog_id = 1 LIMIT 1
116
- # SELECT * FROM posts WHERE blog_id IN (1,2,3,4,5)
117
- ```
118
-
119
- Notice the first call to `blog.posts.exists?` was executed via SQL because the `posts` association wasn't yet loaded. The `fully_load` option can be used to force ActiveRecord to fully load the association (and do any necessary automatic eager loading) when evaluating methods like `exists?`:
120
-
121
- ```
122
- class Blog < ActiveRecord::Base
123
- has_many :posts, fully_load: true
124
- end
125
- ```
126
-
127
- ## Limitations
128
-
129
- Goldiloader leverages the ActiveRecord eager loader so it shares some of the same limitations.
130
-
131
- ### has_one associations that rely on a SQL limit
132
-
133
- You should not try to auto eager load (or regular eager load) `has_one` associations that actually correspond to multiple records and rely on a SQL limit to only return one record. Consider the following example:
134
-
135
- ```
136
- class Blog < ActiveRecord::Base
137
- has_many :posts
138
- has_one :most_recent_post, -> { order(published_at: desc) }, class_name: 'Post'
139
- end
140
- ```
141
-
142
- With standard Rails lazy loading the `most_recent_post` association is loaded with a query like this:
143
-
144
- ```
145
- SELECT * FROM posts WHERE blog_id = 1 ORDER BY published_at DESC LIMIT 1
146
- ```
147
-
148
- With auto eager loading (or regular eager loading) the `most_recent_post` association is loaded with a query like this:
149
-
150
- ```
151
- SELECT * FROM posts WHERE blog_id IN (1,2,3,4,5) ORDER BY published_at DESC
152
- ```
153
-
154
- Notice the SQL limit can no longer be used which results in fetching all posts for each blog. This can cause severe performance problems if there are a large number of posts.
155
-
156
- ### Other Limitations
157
-
158
- Associations with any of the following options cannot be eager loaded:
159
-
160
- * `limit`
161
- * `offset`
162
- * `finder_sql`
163
- * `group` (due to a Rails bug)
164
- * `from` (due to a Rails bug)
165
- * `unscope` (due to a Rails bug)
166
- * `joins` (due to a Rails bug)
167
- * `uniq` (only Rails 3.2 - due to a Rails bug)
168
-
169
- Goldiloader detects associations with any of these options and disables automatic eager loading on them.
170
-
171
- ## Status
172
-
173
- This gem is tested with Rails 3.2, 4.0, 4.1, and 4.2 using MRI 1.9.3, 2.0.0, 2.1.0 and JRuby in 1.9 mode.
174
-
175
- Let us know if you find any issues or have any other feedback.
176
-
177
- ## Change log
178
-
179
- See the [change log](https://github.com/salsify/goldiloader/blob/master/CHANGELOG.md).
180
-
181
- ## Contributing
182
-
183
- 1. Fork it
184
- 2. Create your feature branch (`git checkout -b my-new-feature`)
185
- 3. Commit your changes (`git commit -am 'Add some feature'`)
186
- 4. Push to the branch (`git push origin my-new-feature`)
187
- 5. Create new Pull Request
data/Rakefile DELETED
@@ -1,9 +0,0 @@
1
- require 'bundler/setup'
2
- Bundler::GemHelper.install_tasks
3
-
4
- require 'rspec/core/rake_task'
5
- RSpec::Core::RakeTask.new(:spec) do |task|
6
- task.verbose = false
7
- end
8
-
9
- task default: :spec
data/goldiloader.gemspec DELETED
@@ -1,37 +0,0 @@
1
- # encoding: UTF-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'goldiloader/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'goldiloader'
8
- spec.version = Goldiloader::VERSION
9
- spec.authors = ['Joel Turkel']
10
- spec.email = ['jturkel@salsify.com']
11
- spec.description = %q{Automatically eager loads Rails associations as associations are traversed}
12
- spec.summary = %q{Automatic Rails association eager loading}
13
- spec.homepage = 'https://github.com/salsify/goldiloader'
14
- spec.license = 'MIT'
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.test_files = Dir.glob('spec/**/*')
18
- spec.require_paths = ['lib']
19
-
20
- spec.add_dependency 'activerecord', ENV.fetch('RAILS_VERSION', ['>= 3.2', '< 4.3'])
21
- spec.add_dependency 'activesupport', ENV.fetch('RAILS_VERSION', ['>= 3.2', '< 4.3'])
22
-
23
- spec.add_development_dependency 'coveralls'
24
- spec.add_development_dependency 'database_cleaner', '>= 1.2'
25
- spec.add_development_dependency 'rake'
26
- spec.add_development_dependency 'rspec', '~> 2'
27
- spec.add_development_dependency 'simplecov', '~> 0.7.1'
28
-
29
- if RUBY_PLATFORM == 'java'
30
- spec.add_development_dependency 'jdbc-sqlite3'
31
- spec.add_development_dependency 'activerecord-jdbcsqlite3-adapter'
32
- else
33
- spec.add_development_dependency 'sqlite3'
34
- end
35
-
36
- end
37
-
data/spec/db/database.yml DELETED
@@ -1,3 +0,0 @@
1
- sqlite3:
2
- adapter: sqlite3
3
- database: ":memory:"