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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0959f01a0d8c87999c526ccdafd93755595d0fd
4
- data.tar.gz: 397908ac37b04fa81afe558d14bfedbd5d4df1ca
3
+ metadata.gz: c360d877be5435f7217a91ab76ba418c519d9585
4
+ data.tar.gz: 968eb4b78136d091e6a60de3f6277e8ca6d41607
5
5
  SHA512:
6
- metadata.gz: ac93a58ae02e8b298c6652af9f82c123d6fe826fe4058903941b67010e0a77851dfe7096fc12648eade0de1bd3ca735825fa98c0b21c5fe86c62d6b000752b0a
7
- data.tar.gz: cdc82b4b4e56b64bba76aebf01dffb9461b2caacc202360cbe2c60662daf0145f2dd959ebdb0d12b7b87577ea394b10aa3d3b5478ac103b7a10c33ea8aed1924
6
+ metadata.gz: 01a5390f5cd9a6ccfd8ee59bf5113b66c7babe1b03bbc5ea937ec027b210e6c45a2e7e00ba87a7646b469ea549688df36e40a2f0646e0e8cf73aac196b16fcc1
7
+ data.tar.gz: 94c39a5b6e1e2f64665d1e41f7092283efa4720b0ed324cd27ee9f6be4a98704e772eec835ce941b0953cc51871fc9534db0ebbabfc5c72a83640efc33e9f6fb
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ColumnsOnDemand
2
- VERSION = '4.1.0'
2
+ VERSION = '4.1.1'
3
3
  end
@@ -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
- assert_equal "This is the file data!", record.read_attribute_before_type_cast("file_data")
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
- assert_equal "This is the file data!", record.instance_variable_get("@attributes")["file_data"] # already loaded, overriding default
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
@@ -6,6 +6,7 @@ else
6
6
  end
7
7
 
8
8
  puts "Rails: #{ENV['RAILS_VERSION'] || 'default'}"
9
+ puts "Env: #{ENV['RAILS_ENV'] || 'not set'}"
9
10
  gem 'activesupport', ENV['RAILS_VERSION']
10
11
  gem 'activerecord', ENV['RAILS_VERSION']
11
12
 
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.0
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-15 00:00:00.000000000 Z
11
+ date: 2014-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord