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 +4 -4
 - data/Gemfile +2 -1
 - data/lib/columns_on_demand.rb +2 -2
 - data/lib/columns_on_demand/version.rb +1 -1
 - data/test/columns_on_demand_test.rb +24 -0
 - 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: 8ea8794dded2d78daf705ceaab6df85b8a150fcb
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 0549493f7b65d99480413e6a24d5016d76984251
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 7f984d613b9eeccb2d14fab83e1dd6948a970d3b482876e6095a6605674bf80b8878afd4ec19b8206a4c830341e3b05ac52a7fb30d40f08ff7edfb8198e630da
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: ae1a56951d46b3703d3156d2275a099a0de958139c6b978c5805064ce28f7b2ddb361458b6462388346cf580de233bfbc95d9f1228694bd5989e40095a80f70f
         
     | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/lib/columns_on_demand.rb
    CHANGED
    
    | 
         @@ -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)        
         
     | 
| 
         @@ -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. 
     | 
| 
      
 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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-06-07 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activerecord
         
     |