columns_on_demand 3.0.2 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +2 -0
- data/columns_on_demand.gemspec +1 -4
- data/lib/columns_on_demand.rb +6 -6
- data/lib/columns_on_demand/version.rb +1 -1
- data/test/activerecord_count_queries.rb +14 -19
- data/test/columns_on_demand_test.rb +34 -23
- data/test/test_helper.rb +1 -1
- metadata +101 -125
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c0959f01a0d8c87999c526ccdafd93755595d0fd
|
4
|
+
data.tar.gz: 397908ac37b04fa81afe558d14bfedbd5d4df1ca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ac93a58ae02e8b298c6652af9f82c123d6fe826fe4058903941b67010e0a77851dfe7096fc12648eade0de1bd3ca735825fa98c0b21c5fe86c62d6b000752b0a
|
7
|
+
data.tar.gz: cdc82b4b4e56b64bba76aebf01dffb9461b2caacc202360cbe2c60662daf0145f2dd959ebdb0d12b7b87577ea394b10aa3d3b5478ac103b7a10c33ea8aed1924
|
data/Gemfile
CHANGED
data/columns_on_demand.gemspec
CHANGED
@@ -26,10 +26,7 @@ Compatibility
|
|
26
26
|
|
27
27
|
Supports mysql, mysql2, postgresql, and sqlite3.
|
28
28
|
|
29
|
-
Currently tested against Rails 3.2.
|
30
|
-
Was also tested compatible with 2.3.14 and 3.0.17.
|
31
|
-
|
32
|
-
Note that 3.0 and 3.1 have ActiveRecord regressions that will affect sqlite users.
|
29
|
+
Currently tested against Rails 3.2.18, 4.0.8, and 4.1.4, on Ruby 2.0.0.
|
33
30
|
EOF
|
34
31
|
gem.has_rdoc = false
|
35
32
|
gem.author = "Will Bryant"
|
data/lib/columns_on_demand.rb
CHANGED
@@ -74,10 +74,10 @@ module ColumnsOnDemand
|
|
74
74
|
|
75
75
|
def load_attributes(*attr_names)
|
76
76
|
return if attr_names.blank?
|
77
|
-
values = connection.select_rows(
|
78
|
-
"SELECT #{attr_names.collect {|attr_name| connection.quote_column_name(attr_name)}.join(", ")}" +
|
77
|
+
values = self.class.connection.select_rows(
|
78
|
+
"SELECT #{attr_names.collect {|attr_name| self.class.connection.quote_column_name(attr_name)}.join(", ")}" +
|
79
79
|
" FROM #{self.class.quoted_table_name}" +
|
80
|
-
" WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quote_value(id, self.class.columns_hash[self.class.primary_key])}")
|
80
|
+
" WHERE #{self.class.connection.quote_column_name(self.class.primary_key)} = #{self.class.quote_value(id, self.class.columns_hash[self.class.primary_key])}")
|
81
81
|
row = values.first || raise(ActiveRecord::RecordNotFound, "Couldn't find #{self.class.name} with ID=#{id}")
|
82
82
|
attr_names.each_with_index do |attr_name, i|
|
83
83
|
columns_loaded << attr_name
|
@@ -101,9 +101,9 @@ module ColumnsOnDemand
|
|
101
101
|
load_attributes(attr_name.to_s) unless column_loaded?(attr_name.to_s)
|
102
102
|
end
|
103
103
|
|
104
|
-
def read_attribute_with_columns_on_demand(attr_name)
|
104
|
+
def read_attribute_with_columns_on_demand(attr_name, &block)
|
105
105
|
ensure_loaded(attr_name)
|
106
|
-
read_attribute_without_columns_on_demand(attr_name)
|
106
|
+
read_attribute_without_columns_on_demand(attr_name, &block)
|
107
107
|
end
|
108
108
|
|
109
109
|
def read_attribute_before_type_cast_with_columns_on_demand(attr_name)
|
@@ -130,7 +130,7 @@ module ColumnsOnDemand
|
|
130
130
|
module RelationMethods
|
131
131
|
def build_select_with_columns_on_demand(arel, selects)
|
132
132
|
if selects.empty? && klass < ColumnsOnDemand::InstanceMethods
|
133
|
-
build_select_without_columns_on_demand(arel, default_select(true))
|
133
|
+
build_select_without_columns_on_demand(arel, [default_select(true)])
|
134
134
|
else
|
135
135
|
build_select_without_columns_on_demand(arel, selects)
|
136
136
|
end
|
@@ -1,19 +1,6 @@
|
|
1
|
-
if ActiveRecord::VERSION::MAJOR
|
2
|
-
# proudly stolen from ActiveRecord's test suite, with addition of BEGIN and COMMIT
|
3
|
-
ActiveRecord::Base.connection.class.class_eval do
|
4
|
-
IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /SHOW FIELDS/, /^BEGIN$/, /^COMMIT$/]
|
5
|
-
|
6
|
-
def execute_with_query_record(sql, name = nil, &block)
|
7
|
-
$queries_executed ||= []
|
8
|
-
$queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r }
|
9
|
-
execute_without_query_record(sql, name, &block)
|
10
|
-
end
|
11
|
-
|
12
|
-
alias_method_chain :execute, :query_record
|
13
|
-
end
|
14
|
-
elsif ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR < 2
|
1
|
+
if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR < 2
|
15
2
|
# this is from 3.1's test suite. ugly.
|
16
|
-
class
|
3
|
+
class SQLCounter
|
17
4
|
cattr_accessor :ignored_sql
|
18
5
|
self.ignored_sql = [/^PRAGMA (?!(table_info))/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /^SHOW max_identifier_length/, /^BEGIN/, /^COMMIT/]
|
19
6
|
|
@@ -21,10 +8,14 @@ elsif ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR < 2
|
|
21
8
|
# ignored SQL. This ignored SQL is for Oracle.
|
22
9
|
ignored_sql.concat [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from all_triggers/im]
|
23
10
|
|
24
|
-
def
|
11
|
+
def self.clear_log
|
25
12
|
$queries_executed = []
|
26
13
|
end
|
27
14
|
|
15
|
+
def initialize
|
16
|
+
$queries_executed.clear
|
17
|
+
end
|
18
|
+
|
28
19
|
def call(name, start, finish, message_id, values)
|
29
20
|
sql = values[:sql]
|
30
21
|
|
@@ -36,10 +27,10 @@ elsif ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR < 2
|
|
36
27
|
end
|
37
28
|
end
|
38
29
|
end
|
39
|
-
ActiveSupport::Notifications.subscribe('sql.active_record',
|
30
|
+
ActiveSupport::Notifications.subscribe('sql.active_record', SQLCounter.new)
|
40
31
|
else
|
41
32
|
# this is from 3.2's test suite. ugly.
|
42
|
-
class
|
33
|
+
class SQLCounter
|
43
34
|
cattr_accessor :ignored_sql
|
44
35
|
self.ignored_sql = [/^PRAGMA (?!(table_info))/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /^SHOW max_identifier_length/, /^BEGIN/, /^COMMIT/]
|
45
36
|
|
@@ -52,6 +43,10 @@ else
|
|
52
43
|
|
53
44
|
attr_reader :ignore
|
54
45
|
|
46
|
+
def self.clear_log
|
47
|
+
self.log.clear
|
48
|
+
end
|
49
|
+
|
55
50
|
def initialize(ignore = self.class.ignored_sql)
|
56
51
|
@ignore = ignore
|
57
52
|
end
|
@@ -66,5 +61,5 @@ else
|
|
66
61
|
end
|
67
62
|
end
|
68
63
|
|
69
|
-
ActiveSupport::Notifications.subscribe('sql.active_record',
|
64
|
+
ActiveSupport::Notifications.subscribe('sql.active_record', SQLCounter.new)
|
70
65
|
end
|
@@ -22,7 +22,7 @@ class Child < ActiveRecord::Base
|
|
22
22
|
belongs_to :parent
|
23
23
|
end
|
24
24
|
|
25
|
-
class ColumnsOnDemandTest <
|
25
|
+
class ColumnsOnDemandTest < ActiveSupport::TestCase
|
26
26
|
def assert_not_loaded(record, attr_name)
|
27
27
|
assert !record.column_loaded?(attr_name.to_s)
|
28
28
|
end
|
@@ -31,6 +31,17 @@ class ColumnsOnDemandTest < ActiveRecord::TestCase
|
|
31
31
|
assert record.column_loaded?(attr_name.to_s)
|
32
32
|
end
|
33
33
|
|
34
|
+
def assert_queries(num = 1)
|
35
|
+
::SQLCounter.clear_log
|
36
|
+
yield
|
37
|
+
ensure
|
38
|
+
assert_equal num, ::SQLCounter.log.size, "#{::SQLCounter.log.size} instead of #{num} queries were executed.#{::SQLCounter.log.size == 0 ? '' : "\nQueries:\n#{::SQLCounter.log.join("\n")}"}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def assert_no_queries(&block)
|
42
|
+
assert_queries(0, &block)
|
43
|
+
end
|
44
|
+
|
34
45
|
fixtures :all
|
35
46
|
self.use_transactional_fixtures = true
|
36
47
|
|
@@ -51,35 +62,35 @@ class ColumnsOnDemandTest < ActiveRecord::TestCase
|
|
51
62
|
end
|
52
63
|
|
53
64
|
test "it doesn't load the columns_to_load_on_demand straight away when finding the records" do
|
54
|
-
record = Implicit.
|
65
|
+
record = Implicit.first
|
55
66
|
assert_not_equal nil, record
|
56
67
|
assert_not_loaded record, "file_data"
|
57
68
|
assert_not_loaded record, "processing_log"
|
58
69
|
|
59
|
-
record = Implicit.
|
70
|
+
record = Implicit.all.to_a.first
|
60
71
|
assert_not_equal nil, record
|
61
72
|
assert_not_loaded record, "file_data"
|
62
73
|
assert_not_loaded record, "processing_log"
|
63
74
|
end
|
64
75
|
|
65
76
|
test "it loads the columns when accessed as an attribute" do
|
66
|
-
record = Implicit.
|
77
|
+
record = Implicit.first
|
67
78
|
assert_equal "This is the file data!", record.file_data
|
68
79
|
assert_equal "Processed 0 entries OK", record.results
|
69
80
|
assert_equal record.results.object_id, record.results.object_id # should not have to re-find
|
70
81
|
|
71
|
-
record = Implicit.
|
82
|
+
record = Implicit.all.to_a.first
|
72
83
|
assert_not_equal nil, record.file_data
|
73
84
|
end
|
74
85
|
|
75
86
|
test "it loads the columns only once even if nil" do
|
76
|
-
record = Implicit.
|
87
|
+
record = Implicit.first
|
77
88
|
assert_not_loaded record, "file_data"
|
78
89
|
assert_equal "This is the file data!", record.file_data
|
79
90
|
assert_loaded record, "file_data"
|
80
91
|
Implicit.update_all(:file_data => nil)
|
81
92
|
|
82
|
-
record = Implicit.
|
93
|
+
record = Implicit.first
|
83
94
|
assert_not_loaded record, "file_data"
|
84
95
|
assert_equal nil, record.file_data
|
85
96
|
assert_loaded record, "file_data"
|
@@ -89,7 +100,7 @@ class ColumnsOnDemandTest < ActiveRecord::TestCase
|
|
89
100
|
end
|
90
101
|
|
91
102
|
test "it loads the column when accessed using read_attribute" do
|
92
|
-
record = Implicit.
|
103
|
+
record = Implicit.first
|
93
104
|
assert_equal "This is the file data!", record.read_attribute(:file_data)
|
94
105
|
assert_equal "This is the file data!", record.read_attribute("file_data")
|
95
106
|
assert_equal "Processed 0 entries OK", record.read_attribute("results")
|
@@ -97,19 +108,19 @@ class ColumnsOnDemandTest < ActiveRecord::TestCase
|
|
97
108
|
end
|
98
109
|
|
99
110
|
test "it loads the column when accessed using read_attribute_before_type_cast" do
|
100
|
-
record = Implicit.
|
111
|
+
record = Implicit.first
|
101
112
|
assert_equal "This is the file data!", record.read_attribute_before_type_cast("file_data")
|
102
113
|
assert_equal "Processed 0 entries OK", record.read_attribute_before_type_cast("results")
|
103
114
|
# read_attribute_before_type_cast doesn't tolerate symbol arguments as read_attribute does
|
104
115
|
end
|
105
116
|
|
106
117
|
test "it loads the column when generating #attributes" do
|
107
|
-
attributes = Implicit.
|
118
|
+
attributes = Implicit.first.attributes
|
108
119
|
assert_equal "This is the file data!", attributes["file_data"]
|
109
120
|
end
|
110
121
|
|
111
122
|
test "loads all the columns in one query when generating #attributes" do
|
112
|
-
record = Implicit.
|
123
|
+
record = Implicit.first
|
113
124
|
assert_queries(1) do
|
114
125
|
attributes = record.attributes
|
115
126
|
assert_equal "This is the file data!", attributes["file_data"]
|
@@ -119,20 +130,20 @@ class ColumnsOnDemandTest < ActiveRecord::TestCase
|
|
119
130
|
|
120
131
|
test "it loads the column when generating #to_json" do
|
121
132
|
ActiveRecord::Base.include_root_in_json = true
|
122
|
-
json = Implicit.
|
133
|
+
json = Implicit.first.to_json
|
123
134
|
assert_equal "This is the file data!", ActiveSupport::JSON.decode(json)["implicit"]["file_data"]
|
124
135
|
end
|
125
136
|
|
126
137
|
test "it loads the column for #clone" do
|
127
|
-
record = Implicit.
|
138
|
+
record = Implicit.first.clone
|
128
139
|
assert_equal "This is the file data!", record.file_data
|
129
140
|
|
130
|
-
record = Implicit.
|
141
|
+
record = Implicit.first.clone.tap(&:save!)
|
131
142
|
assert_equal "This is the file data!", Implicit.find(record.id).file_data
|
132
143
|
end
|
133
144
|
|
134
145
|
test "it clears the column on reload, and can load it again" do
|
135
|
-
record = Implicit.
|
146
|
+
record = Implicit.first
|
136
147
|
old_object_id = record.file_data.object_id
|
137
148
|
Implicit.update_all(:file_data => "New file data")
|
138
149
|
|
@@ -142,8 +153,8 @@ class ColumnsOnDemandTest < ActiveRecord::TestCase
|
|
142
153
|
assert_equal "New file data", record.file_data
|
143
154
|
end
|
144
155
|
|
145
|
-
test "it doesn't override custom
|
146
|
-
record = Implicit.
|
156
|
+
test "it doesn't override custom select() finds" do
|
157
|
+
record = Implicit.select("id, file_data").first
|
147
158
|
klass = ActiveRecord.const_defined?(:MissingAttributeError) ? ActiveRecord::MissingAttributeError : ActiveModel::MissingAttributeError
|
148
159
|
assert_raise klass do
|
149
160
|
record.processed_at # explicitly not loaded, overriding default
|
@@ -152,7 +163,7 @@ class ColumnsOnDemandTest < ActiveRecord::TestCase
|
|
152
163
|
end
|
153
164
|
|
154
165
|
test "it raises normal ActiveRecord::RecordNotFound if the record is deleted before the column load" do
|
155
|
-
record = Implicit.
|
166
|
+
record = Implicit.first
|
156
167
|
Implicit.delete_all
|
157
168
|
|
158
169
|
assert_raise ActiveRecord::RecordNotFound do
|
@@ -161,7 +172,7 @@ class ColumnsOnDemandTest < ActiveRecord::TestCase
|
|
161
172
|
end
|
162
173
|
|
163
174
|
test "it doesn't raise on column access if the record is deleted after the column load" do
|
164
|
-
record = Implicit.
|
175
|
+
record = Implicit.first
|
165
176
|
record.file_data
|
166
177
|
Implicit.delete_all
|
167
178
|
|
@@ -218,7 +229,7 @@ class ColumnsOnDemandTest < ActiveRecord::TestCase
|
|
218
229
|
|
219
230
|
test "it works on child records loaded from associations" do
|
220
231
|
parent = parents(:some_parent)
|
221
|
-
child = parent.children.
|
232
|
+
child = parent.children.first
|
222
233
|
assert_not_loaded child, "test_data"
|
223
234
|
assert_equal "Some test data", child.test_data
|
224
235
|
end
|
@@ -232,7 +243,7 @@ class ColumnsOnDemandTest < ActiveRecord::TestCase
|
|
232
243
|
|
233
244
|
test "it doesn't break validates_presence_of" do
|
234
245
|
class ValidatedImplicit < ActiveRecord::Base
|
235
|
-
|
246
|
+
self.table_name = "implicits"
|
236
247
|
columns_on_demand
|
237
248
|
validates_presence_of :original_filename, :file_data, :results
|
238
249
|
end
|
@@ -254,7 +265,7 @@ class ColumnsOnDemandTest < ActiveRecord::TestCase
|
|
254
265
|
original_record = Serializing.create!(:data => data)
|
255
266
|
assert_equal data, original_record.data
|
256
267
|
|
257
|
-
record = Serializing.
|
268
|
+
record = Serializing.first
|
258
269
|
assert_not_loaded record, "data"
|
259
270
|
assert_equal data, record.data
|
260
271
|
assert_equal false, record.data_changed?
|
@@ -266,7 +277,7 @@ class ColumnsOnDemandTest < ActiveRecord::TestCase
|
|
266
277
|
assert_equal true, record.changed?
|
267
278
|
record.save!
|
268
279
|
|
269
|
-
record = Serializing.
|
280
|
+
record = Serializing.first
|
270
281
|
assert_not_loaded record, "data"
|
271
282
|
assert_equal "replacement", record.data
|
272
283
|
end
|
data/test/test_helper.rb
CHANGED
@@ -9,7 +9,7 @@ puts "Rails: #{ENV['RAILS_VERSION'] || 'default'}"
|
|
9
9
|
gem 'activesupport', ENV['RAILS_VERSION']
|
10
10
|
gem 'activerecord', ENV['RAILS_VERSION']
|
11
11
|
|
12
|
-
require '
|
12
|
+
require 'minitest/autorun'
|
13
13
|
require 'active_support'
|
14
14
|
require 'active_support/test_case'
|
15
15
|
require 'active_record'
|
metadata
CHANGED
@@ -1,140 +1,126 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: columns_on_demand
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 3
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 3.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 4.1.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Will Bryant
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-07-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: activerecord
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
32
20
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: rake
|
36
21
|
prerelease: false
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
46
34
|
type: :development
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: mysql
|
50
35
|
prerelease: false
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mysql
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
60
48
|
type: :development
|
61
|
-
version_requirements: *id003
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: mysql2
|
64
49
|
prerelease: false
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mysql2
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
74
62
|
type: :development
|
75
|
-
version_requirements: *id004
|
76
|
-
- !ruby/object:Gem::Dependency
|
77
|
-
name: pg
|
78
63
|
prerelease: false
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pg
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
88
76
|
type: :development
|
89
|
-
version_requirements: *id005
|
90
|
-
- !ruby/object:Gem::Dependency
|
91
|
-
name: sqlite3
|
92
77
|
prerelease: false
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sqlite3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
102
90
|
type: :development
|
103
|
-
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
104
97
|
description: |
|
105
98
|
Lazily loads large columns on demand.
|
106
|
-
|
99
|
+
|
107
100
|
By default, does this for all TEXT (:text) and BLOB (:binary) columns, but a list
|
108
101
|
of specific columns to load on demand can be given.
|
109
|
-
|
102
|
+
|
110
103
|
This is useful to reduce the memory taken by Rails when loading a number of records
|
111
104
|
that have large columns if those particular columns are actually not required most
|
112
105
|
of the time. In this situation it can also greatly reduce the database query time
|
113
106
|
because loading large BLOB/TEXT columns generally means seeking to other database
|
114
107
|
pages since they are not stored wholly in the record's page itself.
|
115
|
-
|
108
|
+
|
116
109
|
Although this plugin is mainly used for BLOB and TEXT columns, it will actually
|
117
110
|
work on all types - and is just as useful for large string fields etc.
|
118
|
-
|
119
|
-
|
111
|
+
|
112
|
+
|
120
113
|
Compatibility
|
121
114
|
=============
|
122
|
-
|
115
|
+
|
123
116
|
Supports mysql, mysql2, postgresql, and sqlite3.
|
124
|
-
|
125
|
-
Currently tested against Rails 3.2.13 and 3.1.8, on Ruby 1.8.7 and 2.0.0p0.
|
126
|
-
Was also tested compatible with 2.3.14 and 3.0.17.
|
127
|
-
|
128
|
-
Note that 3.0 and 3.1 have ActiveRecord regressions that will affect sqlite users.
|
129
117
|
|
118
|
+
Currently tested against Rails 3.2.18, 4.0.8, and 4.1.4, on Ruby 2.0.0.
|
130
119
|
email: will.bryant@gmail.com
|
131
120
|
executables: []
|
132
|
-
|
133
121
|
extensions: []
|
134
|
-
|
135
122
|
extra_rdoc_files: []
|
136
|
-
|
137
|
-
files:
|
123
|
+
files:
|
138
124
|
- .gitignore
|
139
125
|
- Gemfile
|
140
126
|
- MIT-LICENSE
|
@@ -154,38 +140,28 @@ files:
|
|
154
140
|
- test/test_helper.rb
|
155
141
|
homepage: http://github.com/willbryant/columns_on_demand
|
156
142
|
licenses: []
|
157
|
-
|
143
|
+
metadata: {}
|
158
144
|
post_install_message:
|
159
145
|
rdoc_options: []
|
160
|
-
|
161
|
-
require_paths:
|
146
|
+
require_paths:
|
162
147
|
- lib
|
163
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
none: false
|
174
|
-
requirements:
|
175
|
-
- - ">="
|
176
|
-
- !ruby/object:Gem::Version
|
177
|
-
hash: 3
|
178
|
-
segments:
|
179
|
-
- 0
|
180
|
-
version: "0"
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
181
158
|
requirements: []
|
182
|
-
|
183
159
|
rubyforge_project:
|
184
|
-
rubygems_version:
|
160
|
+
rubygems_version: 2.2.2
|
185
161
|
signing_key:
|
186
|
-
specification_version:
|
162
|
+
specification_version: 4
|
187
163
|
summary: Lazily loads large columns on demand.
|
188
|
-
test_files:
|
164
|
+
test_files:
|
189
165
|
- test/activerecord_count_queries.rb
|
190
166
|
- test/columns_on_demand_test.rb
|
191
167
|
- test/database.yml
|