columns_on_demand 4.2.1.1 → 4.2.2
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/{README → README.md} +22 -12
- data/lib/columns_on_demand.rb +1 -2
- data/lib/columns_on_demand/version.rb +1 -1
- data/test/columns_on_demand_test.rb +7 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 638b2974e1909f9b850d1e28e99ef45a309933a9
|
4
|
+
data.tar.gz: 5f7121e622e2bfe7bd2e3d3aecfae2653da6f6ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c0a220f43a19fa785ed29c5d6123d65c9a2871d4c4bce45288892e5b75ea86bd1f80edb9b2d75b3d7829f7921e8259f5c0496f58e09956e5e40095d43f344ea
|
7
|
+
data.tar.gz: 21e381f3de987db40cc5c2c349fb9c8bbfc90845f0f2d81aa0ff08fd75eb98226e8bde70d478e414e142f3a88d227776e1df87b3f7a3ab56fc06be4e832d1c7a
|
data/{README → README.md}
RENAMED
@@ -21,7 +21,7 @@ Compatibility
|
|
21
21
|
|
22
22
|
Supports mysql, mysql2, postgresql, and sqlite3.
|
23
23
|
|
24
|
-
Currently tested against Rails 4.2.
|
24
|
+
Currently tested against Rails 4.2.3, 4.1.12, 4.0.13, 3.2.18, on Ruby 2.1.5.
|
25
25
|
|
26
26
|
Was also previously tested compatible with 2.3.14, 3.0.17, and 3.1.8 on Ruby 2.0.0
|
27
27
|
or 1.8.7 as appropriate, and may still work for them.
|
@@ -30,18 +30,28 @@ or 1.8.7 as appropriate, and may still work for them.
|
|
30
30
|
Example
|
31
31
|
=======
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
class Example
|
37
|
-
columns_on_demand :file_data, :processing_log
|
38
|
-
end
|
33
|
+
`Example.all` will exclude the `file_data` and `processing_log` columns from the
|
34
|
+
`SELECT` query, and `example.file_data` and `example.processing_log` will load & cache
|
35
|
+
that individual column value for the record instance:
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
```ruby
|
38
|
+
class Example
|
39
|
+
columns_on_demand :file_data, :processing_log
|
40
|
+
end
|
41
|
+
```
|
45
42
|
|
43
|
+
Scans the `examples` table columns and registers all TEXT (`:text`) and BLOB (`:binary`) columns for loading on demand:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
class Example
|
47
|
+
columns_on_demand
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
Thanks
|
52
|
+
======
|
53
|
+
|
54
|
+
* Tim Connor (@tlconnor)
|
55
|
+
* Tobias Matthies (@tobmatth)
|
46
56
|
|
47
57
|
Copyright (c) 2008-2015 Will Bryant, Sekuda Ltd, released under the MIT license
|
data/lib/columns_on_demand.rb
CHANGED
@@ -192,8 +192,7 @@ module ColumnsOnDemand
|
|
192
192
|
if select_values.empty? && klass < ColumnsOnDemand::InstanceMethods
|
193
193
|
arel.project(*arel_columns([default_select(true)]))
|
194
194
|
else
|
195
|
-
build_select_without_columns_on_demand(arel)
|
196
|
-
arel.project(*arel_columns(select_values.uniq))
|
195
|
+
build_select_without_columns_on_demand(arel)
|
197
196
|
end
|
198
197
|
end
|
199
198
|
end
|
@@ -290,4 +290,11 @@ class ColumnsOnDemandTest < ActiveSupport::TestCase
|
|
290
290
|
assert_not_loaded record, "data"
|
291
291
|
assert_equal "replacement", record.data
|
292
292
|
end
|
293
|
+
|
294
|
+
test "it doesn't create duplicate columns in SELECT queries" do
|
295
|
+
implicits = Arel::Table.new(:implicits)
|
296
|
+
reference_sql = implicits.project(implicits[:id]).to_sql
|
297
|
+
select_sql = Implicit.select("#{Implicit.quoted_table_name}.#{Implicit.connection.quote_column_name("id")}").to_sql
|
298
|
+
assert_equal select_sql, reference_sql
|
299
|
+
end
|
293
300
|
end
|
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.2.
|
4
|
+
version: 4.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Bryant
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -124,7 +124,7 @@ files:
|
|
124
124
|
- ".gitignore"
|
125
125
|
- Gemfile
|
126
126
|
- MIT-LICENSE
|
127
|
-
- README
|
127
|
+
- README.md
|
128
128
|
- Rakefile
|
129
129
|
- columns_on_demand.gemspec
|
130
130
|
- init.rb
|