pluck_map 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/pluck_map/presenter.rb +27 -1
- data/lib/pluck_map/version.rb +1 -1
- 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: 719535934f95bc4fe3db48d59fb8f8c762f23260c6438763672612d82ea12feb
|
4
|
+
data.tar.gz: ada8d0481118adc7d04f47b3b801e826e4b07a60d07d0d063ef10a652c891568
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d35814e0ef40d24e7ff441250c692880116540f6668ef79ce047da3424e7ff98203964e013f81c4d32d100d4f29e3e3995beb74f7f166ffa4597e5653e893f3
|
7
|
+
data.tar.gz: c887937585d78ef34a9d44e7fedf9ad7810ba9dd5d54525b90c577ca77eaef9450575986adb43c5f9d97d874903a688bf3f81ab538f03b520d4fa849ce0bef7f
|
data/CHANGELOG.md
CHANGED
data/lib/pluck_map/presenter.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "pluck_map/attribute_builder"
|
2
2
|
require "pluck_map/presenters"
|
3
|
+
require "active_record"
|
3
4
|
|
4
5
|
module PluckMap
|
5
6
|
class Presenter
|
@@ -56,7 +57,32 @@ module PluckMap
|
|
56
57
|
end
|
57
58
|
|
58
59
|
def selects
|
59
|
-
attributes.selects
|
60
|
+
@selects ||= attributes.selects.map.with_index { |select, index|
|
61
|
+
|
62
|
+
# Workaround for a bug that exists in Rails at the time of this commit.
|
63
|
+
# See:
|
64
|
+
#
|
65
|
+
# https://github.com/rails/rails/pull/36186
|
66
|
+
#
|
67
|
+
# Prior to the PR above, Rails will treat two results that have the
|
68
|
+
# same name as having the same type. On Postgres, values that are the
|
69
|
+
# result of an expression are given the name of the last function
|
70
|
+
# called in the expression. For example:
|
71
|
+
#
|
72
|
+
# psql> SELECT COALESCE(NULL, 'four'), COALESCE(NULL, 4);
|
73
|
+
# coalesce | coalesce
|
74
|
+
# ----------+----------
|
75
|
+
# four | 4
|
76
|
+
# (1 row)
|
77
|
+
#
|
78
|
+
# This patch mitigates that problem by aliasing SQL expressions before
|
79
|
+
# they are used in select statements.
|
80
|
+
select = select.as("__pluckmap_#{index}") if select.respond_to?(:as)
|
81
|
+
|
82
|
+
# On Rails 4.2, `pluck` can't accept Arel nodes
|
83
|
+
select = Arel.sql(select.to_sql) if ActiveRecord.version.segments.take(2) == [4,2] && select.respond_to?(:to_sql)
|
84
|
+
select
|
85
|
+
}
|
60
86
|
end
|
61
87
|
|
62
88
|
def attributes_by_id
|
data/lib/pluck_map/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pluck_map
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Lail
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|