columns_on_demand 5.2.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +14 -0
- data/Gemfile +1 -0
- data/README.md +3 -4
- data/columns_on_demand.gemspec +0 -9
- data/lib/columns_on_demand.rb +10 -0
- data/lib/columns_on_demand/version.rb +1 -1
- data/test/columns_on_demand_test.rb +13 -4
- data/test_all.sh +11 -3
- metadata +7 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1883a4021dfc69d3c3ce1b12c02f14cfb8d5ad40b7dcf0e382c638ebe20528f1
|
4
|
+
data.tar.gz: b9da84f7409d34203123dc0c9a2c9ed59ed65004cfb08994ad4f13be1e1bad83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25931accb7f33e305383400d6d780d119508298a3ae4baa66fdc374daaf459f47cee7fd7390de790af785075ef7a62b53bd6d79716269487e989952d6979a4c2
|
7
|
+
data.tar.gz: 5477645b767cbc9bf7f9acff349b6fd7c515980905921137f49f8e335c4ed937b89b2cd689f802fd5b296b5129ae1e73899303dd438265af22ca06e36335a3c7
|
data/.travis.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
sudo: false
|
3
|
+
language: ruby
|
4
|
+
cache: bundler
|
5
|
+
dist: bionic
|
6
|
+
rvm:
|
7
|
+
- 2.6
|
8
|
+
services:
|
9
|
+
- postgresql
|
10
|
+
- mysql
|
11
|
+
before_script:
|
12
|
+
- createdb -U postgres columns_on_demand_test
|
13
|
+
- mysqladmin -u root create columns_on_demand_test
|
14
|
+
script: ./test_all.sh
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -21,9 +21,7 @@ Compatibility
|
|
21
21
|
|
22
22
|
Supports mysql, mysql2, postgresql, and sqlite3.
|
23
23
|
|
24
|
-
Currently tested against Rails
|
25
|
-
|
26
|
-
For earlier versions of Rails, use an older version of the gem.
|
24
|
+
Currently tested against Rails 6.1.0.rc1, 6.0.3.4, 5.2.4.4, 5.1.7, and 5.0.7.2, with older gem versions compatible with earlier Rails versions.
|
27
25
|
|
28
26
|
|
29
27
|
Example
|
@@ -53,5 +51,6 @@ Thanks
|
|
53
51
|
* Tim Connor (@tlconnor)
|
54
52
|
* Tobias Matthies (@tobmatth)
|
55
53
|
* Phil Ross (@philr)
|
54
|
+
* Jens Schmidt (@w3dot0)
|
56
55
|
|
57
|
-
Copyright (c) 2008-
|
56
|
+
Copyright (c) 2008-2020 Will Bryant, Sekuda Ltd, released under the MIT license
|
data/columns_on_demand.gemspec
CHANGED
@@ -19,16 +19,7 @@ pages since they are not stored wholly in the record's page itself.
|
|
19
19
|
|
20
20
|
Although this plugin is mainly used for BLOB and TEXT columns, it will actually
|
21
21
|
work on all types - and is just as useful for large string fields etc.
|
22
|
-
|
23
|
-
|
24
|
-
Compatibility
|
25
|
-
=============
|
26
|
-
|
27
|
-
Supports mysql, mysql2, postgresql, and sqlite3.
|
28
|
-
|
29
|
-
Currently tested against Rails 3.2.18, 4.0.8, and 4.1.4, on Ruby 2.0.0.
|
30
22
|
EOF
|
31
|
-
gem.has_rdoc = false
|
32
23
|
gem.author = "Will Bryant"
|
33
24
|
gem.email = "will.bryant@gmail.com"
|
34
25
|
gem.homepage = "http://github.com/willbryant/columns_on_demand"
|
data/lib/columns_on_demand.rb
CHANGED
@@ -107,6 +107,16 @@ module ColumnsOnDemand
|
|
107
107
|
super(attr_name, &block)
|
108
108
|
end
|
109
109
|
|
110
|
+
def write_attribute(attr_name, value)
|
111
|
+
ensure_loaded(attr_name)
|
112
|
+
super(attr_name, value)
|
113
|
+
end
|
114
|
+
|
115
|
+
def _write_attribute(attr_name, value)
|
116
|
+
ensure_loaded(attr_name)
|
117
|
+
super(attr_name, value)
|
118
|
+
end
|
119
|
+
|
110
120
|
def missing_attribute(attr_name, *args)
|
111
121
|
if columns_to_load_on_demand.include?(attr_name)
|
112
122
|
load_attributes(attr_name)
|
@@ -148,6 +148,13 @@ class ColumnsOnDemandTest < ActiveSupport::TestCase
|
|
148
148
|
assert_equal "somefile.txt", attributes["original_filename"]
|
149
149
|
assert_equal "This is the file data!", attributes["file_data"]
|
150
150
|
end
|
151
|
+
|
152
|
+
test "it loads the column when changing its value" do
|
153
|
+
record = Implicit.first
|
154
|
+
record.file_data = 'This is the new file data!'
|
155
|
+
assert_equal "This is the file data!", record.file_data_was
|
156
|
+
assert_equal ["This is the file data!", "This is the new file data!"], record.changes[:file_data]
|
157
|
+
end
|
151
158
|
|
152
159
|
test "it loads the column when generating #to_json" do
|
153
160
|
ActiveRecord::Base.include_root_in_json = true
|
@@ -177,7 +184,8 @@ class ColumnsOnDemandTest < ActiveSupport::TestCase
|
|
177
184
|
|
178
185
|
test "it does not think the column has been loaded if a reloaded instance that has not loaded the attribute is saved" do
|
179
186
|
record = Implicit.first
|
180
|
-
record.
|
187
|
+
record.file_data = "New file data"
|
188
|
+
record.save!
|
181
189
|
|
182
190
|
record.reload
|
183
191
|
record.save!
|
@@ -187,7 +195,8 @@ class ColumnsOnDemandTest < ActiveSupport::TestCase
|
|
187
195
|
|
188
196
|
test "it does not think the column has been loaded if a fresh instance that has not loaded the attribute is saved" do
|
189
197
|
record = Implicit.first
|
190
|
-
record.
|
198
|
+
record.file_data = "New file data"
|
199
|
+
record.save!
|
191
200
|
|
192
201
|
record = Implicit.find(record.id)
|
193
202
|
record.save!
|
@@ -281,9 +290,9 @@ class ColumnsOnDemandTest < ActiveSupport::TestCase
|
|
281
290
|
|
282
291
|
assert !ValidatedImplicit.new(:original_filename => "test.txt").valid?
|
283
292
|
instance = ValidatedImplicit.create!(:original_filename => "test.txt", :file_data => "test file data", :results => "test results")
|
284
|
-
instance.
|
293
|
+
assert instance.valid? # file_data and results are already loaded
|
285
294
|
new_instance = ValidatedImplicit.find(instance.id)
|
286
|
-
new_instance.
|
295
|
+
assert new_instance.valid? # file_data and results aren't loaded yet, but will be loaded to validate
|
287
296
|
end
|
288
297
|
|
289
298
|
test "it works with serialized columns" do
|
data/test_all.sh
CHANGED
@@ -2,10 +2,18 @@
|
|
2
2
|
|
3
3
|
set -e
|
4
4
|
|
5
|
-
for version in
|
5
|
+
for version in 5.0.7.2 5.1.7 5.2.4.4
|
6
6
|
do
|
7
|
-
RAILS_VERSION=$version bundle update rails
|
7
|
+
RAILS_VERSION=$version SQLITE3_VERSION=1.3.9 bundle update rails sqlite3
|
8
8
|
RAILS_ENV=sqlite3 bundle exec rake
|
9
9
|
RAILS_ENV=postgresql bundle exec rake
|
10
10
|
RAILS_ENV=mysql2 bundle exec rake
|
11
|
-
done
|
11
|
+
done
|
12
|
+
|
13
|
+
for version in 6.0.3.4 6.1.0.rc1
|
14
|
+
do
|
15
|
+
RAILS_VERSION=$version SQLITE3_VERSION=1.4.1 bundle update rails sqlite3
|
16
|
+
RAILS_ENV=sqlite3 bundle exec rake
|
17
|
+
RAILS_ENV=postgresql bundle exec rake
|
18
|
+
RAILS_ENV=mysql2 bundle exec rake
|
19
|
+
done
|
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
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Bryant
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -108,20 +108,13 @@ description: |
|
|
108
108
|
|
109
109
|
Although this plugin is mainly used for BLOB and TEXT columns, it will actually
|
110
110
|
work on all types - and is just as useful for large string fields etc.
|
111
|
-
|
112
|
-
|
113
|
-
Compatibility
|
114
|
-
=============
|
115
|
-
|
116
|
-
Supports mysql, mysql2, postgresql, and sqlite3.
|
117
|
-
|
118
|
-
Currently tested against Rails 3.2.18, 4.0.8, and 4.1.4, on Ruby 2.0.0.
|
119
111
|
email: will.bryant@gmail.com
|
120
112
|
executables: []
|
121
113
|
extensions: []
|
122
114
|
extra_rdoc_files: []
|
123
115
|
files:
|
124
116
|
- ".gitignore"
|
117
|
+
- ".travis.yml"
|
125
118
|
- Gemfile
|
126
119
|
- MIT-LICENSE
|
127
120
|
- README.md
|
@@ -143,7 +136,7 @@ homepage: http://github.com/willbryant/columns_on_demand
|
|
143
136
|
licenses:
|
144
137
|
- MIT
|
145
138
|
metadata: {}
|
146
|
-
post_install_message:
|
139
|
+
post_install_message:
|
147
140
|
rdoc_options: []
|
148
141
|
require_paths:
|
149
142
|
- lib
|
@@ -158,9 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
151
|
- !ruby/object:Gem::Version
|
159
152
|
version: '0'
|
160
153
|
requirements: []
|
161
|
-
|
162
|
-
|
163
|
-
signing_key:
|
154
|
+
rubygems_version: 3.0.3
|
155
|
+
signing_key:
|
164
156
|
specification_version: 4
|
165
157
|
summary: Lazily loads large columns on demand.
|
166
158
|
test_files:
|