columns_on_demand 4.2.3 → 4.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf0790eaf4b1e42031300b89dc41c78c3e6d01dd
4
- data.tar.gz: 565cac752b00dd851afae53693338830515ab54f
3
+ metadata.gz: 8ea8794dded2d78daf705ceaab6df85b8a150fcb
4
+ data.tar.gz: 0549493f7b65d99480413e6a24d5016d76984251
5
5
  SHA512:
6
- metadata.gz: ef1f5f0953ae36e854ed4742d51d58e7535091946461f2ca8a9d6fe8df4a0b8efd58f74a9316c6279f30c0ccb0394b4ee401d03b61988ca6a1516669f194a598
7
- data.tar.gz: b00570225d31a37086329a7a55de9c0b72c952e20d3398df241fa3b7b0bbd05d789ad863ebb7229997517a15f50eb4a8db9a651998180f7f4f4f67e624691ae6
6
+ metadata.gz: 7f984d613b9eeccb2d14fab83e1dd6948a970d3b482876e6095a6605674bf80b8878afd4ec19b8206a4c830341e3b05ac52a7fb30d40f08ff7edfb8198e630da
7
+ data.tar.gz: ae1a56951d46b3703d3156d2275a099a0de958139c6b978c5805064ce28f7b2ddb361458b6462388346cf580de233bfbc95d9f1228694bd5989e40095a80f70f
data/Gemfile CHANGED
@@ -10,4 +10,5 @@ gemspec
10
10
  # Git. Remember to move these dependencies to your gemspec before releasing
11
11
  # your gem to rubygems.org.
12
12
 
13
- gem 'rails', ENV['RAILS_VERSION']
13
+ gem 'rails', ENV['RAILS_VERSION']
14
+ gem 'nokogiri', '~> 1.6.7.2'
@@ -179,7 +179,7 @@ module ColumnsOnDemand
179
179
 
180
180
  module RelationMethodsArity2
181
181
  def build_select_with_columns_on_demand(arel, selects)
182
- if selects.empty? && klass < ColumnsOnDemand::InstanceMethods
182
+ if (selects.empty? || selects == [table[Arel.star]] || selects == ['*']) && klass < ColumnsOnDemand::InstanceMethods
183
183
  build_select_without_columns_on_demand(arel, [default_select(true)])
184
184
  else
185
185
  build_select_without_columns_on_demand(arel, selects)
@@ -189,7 +189,7 @@ module ColumnsOnDemand
189
189
 
190
190
  module RelationMethodsArity1
191
191
  def build_select_with_columns_on_demand(arel)
192
- if select_values.empty? && klass < ColumnsOnDemand::InstanceMethods
192
+ if (select_values.empty? || select_values == [table[Arel.star]] || select_values == ['*']) && klass < ColumnsOnDemand::InstanceMethods
193
193
  arel.project(*arel_columns([default_select(true)]))
194
194
  else
195
195
  build_select_without_columns_on_demand(arel)
@@ -1,3 +1,3 @@
1
1
  module ColumnsOnDemand
2
- VERSION = '4.2.3'
2
+ VERSION = '4.3.0'
3
3
  end
@@ -166,6 +166,16 @@ class ColumnsOnDemandTest < ActiveSupport::TestCase
166
166
  end
167
167
  assert_loaded record, :file_data
168
168
  end
169
+
170
+ test "it doesn't load the on demand columns with select *" do
171
+ record = Implicit.select(Implicit.arel_table[Arel.star]).first
172
+ assert_not_loaded record, "file_data"
173
+ assert_not_loaded record, "processing_log"
174
+
175
+ record = Implicit.select('*').first
176
+ assert_not_loaded record, "file_data"
177
+ assert_not_loaded record, "processing_log"
178
+ end
169
179
 
170
180
  test "it raises normal ActiveRecord::RecordNotFound if the record is deleted before the column load" do
171
181
  record = Implicit.first
@@ -246,6 +256,20 @@ class ColumnsOnDemandTest < ActiveSupport::TestCase
246
256
  assert_equal "Here's some info.", parent.info
247
257
  end
248
258
 
259
+ test "it works on child records loaded from associations with includes" do
260
+ parent = Parent.includes(:children).first
261
+ child = parent.children.first
262
+ assert_not_loaded child, "test_data"
263
+ assert_equal "Some test data", child.test_data
264
+ end
265
+
266
+ test "it works on parent records loaded from associations with includes" do
267
+ child = Child.includes(:parent).first
268
+ parent = child.parent
269
+ assert_not_loaded parent, "info"
270
+ assert_equal "Here's some info.", parent.info
271
+ end
272
+
249
273
  test "it doesn't break validates_presence_of" do
250
274
  class ValidatedImplicit < ActiveRecord::Base
251
275
  self.table_name = "implicits"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: columns_on_demand
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.3
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Bryant
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-04 00:00:00.000000000 Z
11
+ date: 2016-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord