columns_on_demand 4.1.0 → 4.1.1
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/lib/columns_on_demand.rb +7 -0
- data/lib/columns_on_demand/version.rb +1 -1
- data/test/columns_on_demand_test.rb +7 -2
- data/test/test_helper.rb +1 -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: c360d877be5435f7217a91ab76ba418c519d9585
         | 
| 4 | 
            +
              data.tar.gz: 968eb4b78136d091e6a60de3f6277e8ca6d41607
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 01a5390f5cd9a6ccfd8ee59bf5113b66c7babe1b03bbc5ea937ec027b210e6c45a2e7e00ba87a7646b469ea549688df36e40a2f0646e0e8cf73aac196b16fcc1
         | 
| 7 | 
            +
              data.tar.gz: 94c39a5b6e1e2f64665d1e41f7092283efa4720b0ed324cd27ee9f6be4a98704e772eec835ce941b0953cc51871fc9534db0ebbabfc5c72a83640efc33e9f6fb
         | 
    
        data/lib/columns_on_demand.rb
    CHANGED
    
    | @@ -84,6 +84,13 @@ module ColumnsOnDemand | |
| 84 84 | 
             
                    @attributes[attr_name] = row[i]
         | 
| 85 85 |  | 
| 86 86 | 
             
                    if coder = self.class.serialized_attributes[attr_name]
         | 
| 87 | 
            +
                      # for some database adapters, @column_types_override gets populated with type data from query used to load the record originally.
         | 
| 88 | 
            +
                      # this is fine, but unfortunately some special-case "decorate_columns" code in ActiveRecord will wrap those types in serialization
         | 
| 89 | 
            +
                      # objects, and it does this for each column listed in @serialized_column_names *even if they are not present in the query results*.
         | 
| 90 | 
            +
                      # as a result it unfortunately overrides the normal @column_type with a @column_type_override with a nil @column, which explodes
         | 
| 91 | 
            +
                      # when it tries to run the typecast.  make it use the normal @column_type value, since we know that we've loading the regular column.
         | 
| 92 | 
            +
                      @column_types_override.delete(attr_name) if @column_types_override
         | 
| 93 | 
            +
             | 
| 87 94 | 
             
                      if ActiveRecord.const_defined?(:AttributeMethods) &&
         | 
| 88 95 | 
             
                         ActiveRecord::AttributeMethods::const_defined?(:Serialization) &&
         | 
| 89 96 | 
             
                         ActiveRecord::AttributeMethods::Serialization::Attribute
         | 
| @@ -109,7 +109,12 @@ class ColumnsOnDemandTest < ActiveSupport::TestCase | |
| 109 109 |  | 
| 110 110 | 
             
              test "it loads the column when accessed using read_attribute_before_type_cast" do
         | 
| 111 111 | 
             
                record = Implicit.first
         | 
| 112 | 
            -
                 | 
| 112 | 
            +
                if Implicit.connection.class.name =~ /PostgreSQL/ && ActiveRecord::VERSION::MAJOR >= 4
         | 
| 113 | 
            +
                  # newer versions of activerecord show the encoded binary format used for blob columns in postgresql in the before_type_cast output, whereas older ones had already decoded that
         | 
| 114 | 
            +
                  assert_equal "\\x54686973206973207468652066696c65206461746121", record.read_attribute_before_type_cast("file_data")
         | 
| 115 | 
            +
                else
         | 
| 116 | 
            +
                  assert_equal "This is the file data!", record.read_attribute_before_type_cast("file_data")
         | 
| 117 | 
            +
                end
         | 
| 113 118 | 
             
                assert_equal "Processed 0 entries OK", record.read_attribute_before_type_cast("results")
         | 
| 114 119 | 
             
                # read_attribute_before_type_cast doesn't tolerate symbol arguments as read_attribute does
         | 
| 115 120 | 
             
              end
         | 
| @@ -159,7 +164,7 @@ class ColumnsOnDemandTest < ActiveSupport::TestCase | |
| 159 164 | 
             
                assert_raise klass do
         | 
| 160 165 | 
             
                  record.processed_at # explicitly not loaded, overriding default
         | 
| 161 166 | 
             
                end
         | 
| 162 | 
            -
                 | 
| 167 | 
            +
                assert_loaded record, :file_data
         | 
| 163 168 | 
             
              end
         | 
| 164 169 |  | 
| 165 170 | 
             
              test "it raises normal ActiveRecord::RecordNotFound if the record is deleted before the column load" do
         | 
    
        data/test/test_helper.rb
    CHANGED
    
    
    
        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.1. | 
| 4 | 
            +
              version: 4.1.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Will Bryant
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-07- | 
| 11 | 
            +
            date: 2014-07-16 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activerecord
         |