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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5fe283d7922a8073591f5c00728e976c3c7ed2ec9dbe51972224b35f55095498
4
- data.tar.gz: ec6c34d345f4ecf01a48d53f266f13b0b91b2a8e87d72c5b5cffffcda6101c36
3
+ metadata.gz: d35dc5f3ef872b957e24553488667ea6e1f948e56d741d6f5dbf5a7612dc1208
4
+ data.tar.gz: 8980c2297bb237b520aafd79177e727c29628b3e807349df8ec153e259f3ccb6
5
5
  SHA512:
6
- metadata.gz: 96bfd6336c293999b0aa436b9d63067a7fb50effb8ac8c4bf17a151b80233765dbff782507546053e62e10e5dd49fa64a70d92cb6a47e0acd0cef2c0ff7c5991
7
- data.tar.gz: c0bbca8dc201efcb927e35e2dc45b39c626a3e81842366b89500b5ca7007a49caa5dee922efd394b987da2f04cd638af03d9573a2fd3df792e8d27f462239770
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.0...HEAD
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
@@ -3,8 +3,8 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 5.0.7"
6
- gem "sqlite3", "~> 1.3.6"
7
- gem "pg"
8
6
  gem "mysql2", '~> 0.4.0'
7
+ gem "pg"
8
+ gem "sqlite3", "~> 1.3.6"
9
9
 
10
10
  gemspec
@@ -3,8 +3,8 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 5.0.7"
6
- gem "sqlite3", "~> 1.3.6"
7
- gem "pg"
8
6
  gem "mysql2"
7
+ gem "pg"
8
+ gem "sqlite3", "~> 1.3.6"
9
9
 
10
10
  gemspec path: "../"
@@ -3,8 +3,8 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 5.1.6"
6
- gem "sqlite3", "~> 1.3.6"
7
- gem "pg"
8
6
  gem "mysql2"
7
+ gem "pg"
8
+ gem "sqlite3", "~> 1.3.6"
9
9
 
10
10
  gemspec path: "../"
@@ -3,8 +3,8 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 5.2.0"
6
- gem "sqlite3"
7
- gem "pg"
8
6
  gem "mysql2"
7
+ gem "pg"
8
+ gem "sqlite3"
9
9
 
10
10
  gemspec path: "../"
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module VirtualAttributes
3
- VERSION = "1.3.0"
3
+ VERSION = "1.3.1"
4
4
  end
5
5
  end
@@ -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.each_with_object({}) do |(parent, child), h|
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.0
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-05-24 00:00:00.000000000 Z
11
+ date: 2019-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord