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 +4 -4
- data/lib/active_record_query_fixer.rb +8 -2
- 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: 6fc75b0466693604d010e4489ac07fd724b21d3f5199b6379b92c3733c342cb4
|
4
|
+
data.tar.gz: bf0a66c2fb45fdcb762058c3749d13fe6273f0eba822462c4c112f7fece00b71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 ||=
|
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
|
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.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-
|
11
|
+
date: 2019-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dig_bang
|