activerecord-virtual_attributes 1.3.0 → 1.3.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/CHANGELOG.md +6 -1
- data/Gemfile +2 -2
- data/gemfiles/virtual_attributes_50.gemfile +2 -2
- data/gemfiles/virtual_attributes_51.gemfile +2 -2
- data/gemfiles/virtual_attributes_52.gemfile +2 -2
- data/lib/active_record/virtual_attributes/version.rb +1 -1
- data/lib/active_record/virtual_attributes/virtual_fields.rb +20 -16
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d35dc5f3ef872b957e24553488667ea6e1f948e56d741d6f5dbf5a7612dc1208
|
|
4
|
+
data.tar.gz: 8980c2297bb237b520aafd79177e727c29628b3e807349df8ec153e259f3ccb6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a42caa72fee1075051551c5c12c14b71696be135ed27eaf755936bde51b63a4953a51458ad22dd7fd40808c2aae9c661b93b0aee5e6a3d684acd85a21461f788
|
|
7
|
+
data.tar.gz: 7ca0eb7fde02046e0921a81d84735be127cd068ee554550fd4dc903da2b105f025064ab3e8a728fb9e26d2586dbd892a569eb8a6cac6557d19770a9fc28945c0
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,10 @@ a nice looking [Changelog](http://keepachangelog.com).
|
|
|
5
5
|
|
|
6
6
|
## Version [Unreleased]
|
|
7
7
|
|
|
8
|
+
## Version [1.3.1] <small>2019-06-06</small>
|
|
9
|
+
|
|
10
|
+
* quote column aliases
|
|
11
|
+
|
|
8
12
|
## Version [1.3.0] <small>2019-05-24</small>
|
|
9
13
|
|
|
10
14
|
* Rails 5.2 support
|
|
@@ -34,7 +38,8 @@ a nice looking [Changelog](http://keepachangelog.com).
|
|
|
34
38
|
* Initial Release
|
|
35
39
|
* Extracted from ManageIQ/manageiq
|
|
36
40
|
|
|
37
|
-
[Unreleased]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v1.3.
|
|
41
|
+
[Unreleased]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v1.3.1...HEAD
|
|
42
|
+
[1.3.1]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v1.3.0...v1.3.1
|
|
38
43
|
[1.3.0]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v1.2.0...v1.3.0
|
|
39
44
|
[1.2.0]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v1.1.0...v1.2.0
|
|
40
45
|
[1.1.0]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v1.0.0...v1.1.0
|
data/Gemfile
CHANGED
|
@@ -39,25 +39,29 @@ module ActiveRecord
|
|
|
39
39
|
when Array
|
|
40
40
|
associations.collect { |association| replace_virtual_fields(association) }.compact
|
|
41
41
|
when Hash
|
|
42
|
-
associations
|
|
43
|
-
if virtual_field?(parent) # form virtual_attribute => {}
|
|
44
|
-
case (new_includes = replace_virtual_fields(virtual_includes(parent)))
|
|
45
|
-
when String, Symbol
|
|
46
|
-
h[new_includes] = {}
|
|
47
|
-
when Array
|
|
48
|
-
new_includes.each { |association| h[association] = {} }
|
|
49
|
-
when Hash
|
|
50
|
-
h.deep_merge!(new_includes)
|
|
51
|
-
end
|
|
52
|
-
else
|
|
53
|
-
reflection = reflect_on_association(parent.to_sym)
|
|
54
|
-
h[parent] = reflection.nil? || reflection.options[:polymorphic] ? {} : reflection.klass.replace_virtual_fields(child) || {}
|
|
55
|
-
end
|
|
56
|
-
end
|
|
42
|
+
replace_virtual_field_hash(associations)
|
|
57
43
|
else
|
|
58
44
|
associations
|
|
59
45
|
end
|
|
60
46
|
end
|
|
47
|
+
|
|
48
|
+
def replace_virtual_field_hash(associations)
|
|
49
|
+
associations.each_with_object({}) do |(parent, child), h|
|
|
50
|
+
if virtual_field?(parent) # form virtual_attribute => {}
|
|
51
|
+
case (new_includes = replace_virtual_fields(virtual_includes(parent)))
|
|
52
|
+
when String, Symbol
|
|
53
|
+
h[new_includes] = {}
|
|
54
|
+
when Array
|
|
55
|
+
new_includes.each { |association| h[association] = {} }
|
|
56
|
+
when Hash
|
|
57
|
+
h.deep_merge!(new_includes)
|
|
58
|
+
end
|
|
59
|
+
else
|
|
60
|
+
reflection = reflect_on_association(parent.to_sym)
|
|
61
|
+
h[parent] = reflection.nil? || reflection.options[:polymorphic] ? {} : reflection.klass.replace_virtual_fields(child) || {}
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
61
65
|
end
|
|
62
66
|
end
|
|
63
67
|
end
|
|
@@ -208,7 +212,7 @@ module ActiveRecord
|
|
|
208
212
|
fields.flatten!
|
|
209
213
|
fields.map! do |field|
|
|
210
214
|
if virtual_attribute?(field) && (arel = klass.arel_attribute(field)) && arel.respond_to?(:as)
|
|
211
|
-
arel.as(field.to_s)
|
|
215
|
+
arel.as(connection.quote_column_name(field.to_s))
|
|
212
216
|
else
|
|
213
217
|
field
|
|
214
218
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-virtual_attributes
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Keenan Brock
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-06-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|