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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19fa73e1ddacc9003ee2eb47d734a7352db57ba07cc3289058f59accb3f6c35f
4
- data.tar.gz: dab480dc00323d18ea6e407514f0d5af914319eaed54a39e251d6198e8c25513
3
+ metadata.gz: 286f64ce0867ac277cd2b0483b86336feeecc0ef1b1bfcb505fe180ceea0037a
4
+ data.tar.gz: d27dfa1586fa4014ceeaeebb221f0e130b65664ae4236d67a57922fdfe4a1475
5
5
  SHA512:
6
- metadata.gz: 71e5ca9135ba7667b3e7da108a9b2543116afa23e8ab1b50a0d0d1a37a291aba82859739c43d2cc1021d29a2466b60ce00633b7624c4a8c17265f97962aa66c9
7
- data.tar.gz: af90fa1f50f0ef0edaa15e95543ec087a870ef0cef1ac79cfcac981eceb56f9a3c4492b3f3a58db7a01306b236f791642b9a3aff2ea554eed28252f52a29f6ac
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
@@ -1,3 +1,3 @@
1
1
  class ActiveRecordQueryFixer
2
- VERSION = "0.0.5".freeze
2
+ VERSION = "0.0.6".freeze
3
3
  end
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.5
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: 2018-12-04 00:00:00.000000000 Z
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.