active_record_distinct_on 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2bdc5ffaa6c0bd2aed0a69fdab6a454a0ca1d5010907a91a3083c47f86e9f5f
4
- data.tar.gz: 4a14067373b241a5f9c816d6dca59edfcb73410aa88929e3d6c6bfc7f94a0d20
3
+ metadata.gz: '03806e7bb7b654ef57351d1b7123f4f07084e256eeb564a4d325b21e2f41bede'
4
+ data.tar.gz: 889c8a393d6c907bae4bb78afe291521e7fafd74f4b77f6190d07cbe39197acc
5
5
  SHA512:
6
- metadata.gz: beaca47b08017c4c728c9d1ddfe30f480e88c5ef12a8905b18e2e6d7791eaee3cd1fa64028ecf89831d57bfe121c45eae29ff398dbfba54ab835ef55ae0ed4dd
7
- data.tar.gz: 3b43fad485e74d7c4e514475962e0280e5ee929a755ef74cc4bea013c5389ef7b6b1305ffdddd908058f7a92b635545a288d575af809bc74fd02bf481699f036
6
+ metadata.gz: 81b62213427b5a7bf5b18b63a508cd0cd454b6b6ae069817b28be2816c5c3df14698cd178589fbd7fcd693d74c3da664b7f867cf36c6ecffa3666bbc10b09ac5
7
+ data.tar.gz: d61728b40cd13d642a6cdb0e73a5e4a9287878d6fbc31ca849eb4c02874bbfd4d467fe4764e862c8ce9e2a8b899724012549fc928a3a62eeef1316ead07297f7
@@ -28,13 +28,6 @@ module ActiveRecordDistinctOn
28
28
 
29
29
  def distinct_on!(*fields)
30
30
  fields.flatten!
31
- fields.map! { |field|
32
- if klass.attribute_alias?(field)
33
- arel_table[klass.attribute_alias(field).to_sym]
34
- else
35
- arel_table[field]
36
- end
37
- }
38
31
  self.distinct_on_values += fields
39
32
  self
40
33
  end
@@ -48,7 +41,16 @@ module ActiveRecordDistinctOn
48
41
  end
49
42
 
50
43
  def build_distinct_on(arel, columns)
51
- arel.distinct_on arel_columns columns unless columns.empty?
44
+ return if columns.empty?
45
+
46
+ arel_attributes = columns.map { |field|
47
+ if klass.attribute_alias?(field)
48
+ arel_table[klass.attribute_alias(field).to_sym]
49
+ else
50
+ arel_table[field]
51
+ end
52
+ }
53
+ arel.distinct_on(arel_columns arel_attributes)
52
54
  end
53
55
  end
54
56
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordDistinctOn
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.0'
3
3
  end
@@ -8,6 +8,7 @@ module ActiveRecordDistinctOn
8
8
  def self.install
9
9
  ActiveRecord::Relation.include DistinctOnQueryMethods
10
10
  ActiveRecord::Querying.delegate :distinct_on, to: :all
11
+ ActiveRecord::Relation::Merger::NORMAL_VALUES << :distinct_on
11
12
  end
12
13
  end
13
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_distinct_on
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alec Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  requirements: []
165
- rubygems_version: 3.1.6
165
+ rubygems_version: 3.2.31
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: Adds support for `DISTINCT ON` statements when querying with ActiveRecord