active_record_distinct_on 1.8.0 → 1.9.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b31fcaef7d64d5c76bdc8bb88fa3f8df1729b684ecd764e2728ca4d6796ee147
|
4
|
+
data.tar.gz: 72323eb638f2d5d40807ea761c2a709eb8fa29541fc0ad02c8ac4240ac6e42b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a110834941290ec4bf2b77fbdd6fbd7f53bb8f8f934111693943a16c809237935ffe5f352847b2b27cdf5340bb1c3626df36a75209d33c11a3bae56856782693
|
7
|
+
data.tar.gz: 10bd0b5744d1f2e691624ebcda00b8304b635d027143473ec389e1a807272715f25e07a26a7a12e075eb51f35e9c3bafc8beed5ad2bc04e0e9a741aa1d7a82ad
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'active_record_distinct_on'
|
2
|
-
|
3
2
|
module ActiveRecordDistinctOn
|
4
3
|
module DistinctOnQueryMethods
|
5
4
|
extend ActiveSupport::Concern
|
@@ -70,15 +69,26 @@ module ActiveRecordDistinctOn
|
|
70
69
|
end
|
71
70
|
|
72
71
|
def distinct_on_arel_columns
|
73
|
-
arel_attributes = distinct_on_values.map
|
74
|
-
if
|
75
|
-
|
72
|
+
arel_attributes = distinct_on_values.map do |field|
|
73
|
+
if field.is_a?(String)
|
74
|
+
field
|
75
|
+
elsif field.is_a?(Hash)
|
76
|
+
assoc = field.keys.first
|
77
|
+
assoc_klass = klass.reflect_on_association(assoc).klass
|
78
|
+
assoc_field = field[assoc].to_sym
|
79
|
+
build_distinct_on_field(assoc_klass, assoc_field)
|
76
80
|
else
|
77
|
-
|
81
|
+
build_distinct_on_field(klass, field)
|
78
82
|
end
|
79
|
-
|
83
|
+
end
|
84
|
+
|
85
|
+
arel_columns(arel_attributes)
|
86
|
+
end
|
87
|
+
|
88
|
+
def build_distinct_on_field(klass, field)
|
89
|
+
return klass.arel_table[klass.attribute_alias(field).to_sym] if klass.attribute_alias?(field)
|
80
90
|
|
81
|
-
|
91
|
+
klass.arel_table[field]
|
82
92
|
end
|
83
93
|
end
|
84
94
|
end
|
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.
|
4
|
+
version: 1.9.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:
|
11
|
+
date: 2025-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|