active_record_query_fixer 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_record_query_fixer.rb +5 -1
- data/lib/active_record_query_fixer/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: 286f64ce0867ac277cd2b0483b86336feeecc0ef1b1bfcb505fe180ceea0037a
|
4
|
+
data.tar.gz: d27dfa1586fa4014ceeaeebb221f0e130b65664ae4236d67a57922fdfe4a1475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 305e9f4a2626d28488593418e5e53f6047675557f2cce27bee031cd22f907704bf188ce820dbfc9017a34cb5f6bfce217c6c6e55eb7c08e7a60a1083fb26d668
|
7
|
+
data.tar.gz: b2068204ae6b377ee409d6a36bd97c8851bb22c742a41ae9f33c36490d09f5777b271e9b1ecb83116b7f87d67f0cbd9edde98c90a2ebfc250c3782eb24865af3
|
@@ -23,7 +23,7 @@ class ActiveRecordQueryFixer
|
|
23
23
|
@query = @query.group(@query.model.arel_table[@query.model.primary_key])
|
24
24
|
|
25
25
|
@query.values[:order]&.each do |order|
|
26
|
-
@query = @query.group(extract_table_and_column_from_expression(order))
|
26
|
+
@query = @query.group(extract_table_and_column_from_expression(order)) if group_by_order?(order)
|
27
27
|
end
|
28
28
|
|
29
29
|
self
|
@@ -77,6 +77,10 @@ private
|
|
77
77
|
def fix_reference_group?
|
78
78
|
@query.values[:references].present? && @query.values[:group].present?
|
79
79
|
end
|
80
|
+
|
81
|
+
def group_by_order?(order)
|
82
|
+
!order.match?(/\A\s*(COUNT|SUM)\(/i)
|
83
|
+
end
|
80
84
|
end
|
81
85
|
|
82
86
|
ActiveRecord::Relation.include ActiveRecordQueryFixer::RelationExtentions
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_query_fixer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A library for automatically added `.select` on a column used for `.distinct`
|
14
14
|
or automatically adding `.group` for a column used for order.
|