active_record_query_fixer 0.0.9 → 0.0.10

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: 211d95cbf9d6f076875db25b572d387ccae0bab79966e5956b407fa585054114
4
- data.tar.gz: 74dd84ce0e7573bd2a52864f02a2b0856d8c11caa45716946880476760a813d0
3
+ metadata.gz: 6fc75b0466693604d010e4489ac07fd724b21d3f5199b6379b92c3733c342cb4
4
+ data.tar.gz: bf0a66c2fb45fdcb762058c3749d13fe6273f0eba822462c4c112f7fece00b71
5
5
  SHA512:
6
- metadata.gz: 497005381f08f135df4b672560b3a200ab9486252a8e1079d5e2f23fd11c6f22479296d9ff2eeada9f0b9d98b82a952ade57fa71f80c568cd43fcd0242a9f505
7
- data.tar.gz: cc59eea2a2f6b2842d8d1583632780b91811171b69f50d3c0fe9fca8d7e78c80453bbc8dfd011c148f6527e2374aaa35729db7ce8c9e70887abfe4e9a36940ff
6
+ metadata.gz: 00f4f4cbaf9d3e81e82c27e1a78a43867b8f511b29d398ff84624d462b7fef370a51b8e15d46e8462791222feb46e7d9a51718cafbec275aecb9a9da224e7c89
7
+ data.tar.gz: 92b877b63ae9e03d15d79ff9611091935aa94983fb7676b8d34a478919c67fc64e108e8f7615662dea586a16b49c2c1569a1880fdac72784b3917c2cc800b267
@@ -95,7 +95,7 @@ class ActiveRecordQueryFixer
95
95
  private
96
96
 
97
97
  def fix_order_group?
98
- @query.values[:joins].blank? && @query.values[:distinct].present? ||
98
+ @query.values[:joins].blank? && @query.values[:distinct].present? && @query.values[:order].present? ||
99
99
  @query.values[:group].present? && @query.values[:order].present?
100
100
  end
101
101
 
@@ -111,11 +111,17 @@ private
111
111
  @parsed_query ||= PgQuery.parse(@query.to_sql)
112
112
  end
113
113
 
114
+ def select_statement
115
+ @select_statement ||= parsed_query.tree.dig!(0, "RawStmt", "stmt", "SelectStmt")
116
+ end
117
+
114
118
  def select_targets
115
- @select_targets ||= parsed_query.tree.dig!(0, "RawStmt", "stmt", "SelectStmt", "targetList")
119
+ @select_targets ||= select_statement.fetch("targetList")
116
120
  end
117
121
 
118
122
  def sort_targets
123
+ return [] unless select_statement.key?("sortClause")
124
+
119
125
  @sort_targets ||= parsed_query.tree.dig!(0, "RawStmt", "stmt", "SelectStmt", "sortClause")
120
126
  end
121
127
  end
@@ -1,3 +1,3 @@
1
1
  class ActiveRecordQueryFixer
2
- VERSION = "0.0.9".freeze
2
+ VERSION = "0.0.10".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.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-20 00:00:00.000000000 Z
11
+ date: 2019-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dig_bang