pattern_query_helper 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/pattern_query_helper.rb +1 -1
- data/lib/pattern_query_helper/filtering.rb +6 -3
- data/lib/pattern_query_helper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f7b769fe7f7c872ae4687971e2b6c584be215602b487b59cc703ef07fdbd33e
|
4
|
+
data.tar.gz: 842ca189e4f4d454c8b73ba07eb9eb116b8f1a29361b64ddad5cef94abca5db4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe96140d39459acc61d3dba075bc87b2068c9e7c686ef2d1e013b1f4026055ff2ab440246cf14ea9f870de975f5fbabf5eb2edd3a1719922b2fdc9f0fac44374
|
7
|
+
data.tar.gz: dda789624d5ef4d5f6239659cc268b7348f26f52c1ca428936c712424be78a3dde297aad937adfb85f0a7c2018dc72fa6e72070f489a3adbbcbf6f5e65b21259
|
data/Gemfile.lock
CHANGED
data/lib/pattern_query_helper.rb
CHANGED
@@ -94,7 +94,7 @@ module PatternQueryHelper
|
|
94
94
|
valid_columns.each do |c|
|
95
95
|
valid_columns_map["#{c}"] = c
|
96
96
|
end
|
97
|
-
filtering = PatternQueryHelper::Filtering.create_filters(query_helpers[:filter], valid_columns_map)
|
97
|
+
filtering = PatternQueryHelper::Filtering.create_filters(filters: query_helpers[:filter], valid_columns_map: valid_columns_map)
|
98
98
|
sorting = PatternQueryHelper::Sorting.parse_sorting_params(query_helpers[:sort], valid_columns)
|
99
99
|
associations = PatternQueryHelper::Associations.process_association_params(query_helpers[:include])
|
100
100
|
pagination = PatternQueryHelper::Pagination.parse_pagination_params(query_helpers[:page], query_helpers[:per_page])
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module PatternQueryHelper
|
2
2
|
class Filtering
|
3
|
-
def self.create_filters(filters
|
3
|
+
def self.create_filters(filters:, valid_columns_map: nil, symbol_prefix: "", include_where: true)
|
4
4
|
filters ||= {}
|
5
5
|
all_conditions = []
|
6
6
|
filter_params = {}
|
@@ -67,8 +67,11 @@ module PatternQueryHelper
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
|
71
|
-
|
70
|
+
if include_where
|
71
|
+
filter_string = "where " + all_conditions.join("\n and ") unless all_conditions.empty?
|
72
|
+
else
|
73
|
+
filter_string = all_conditions.empty? ? "1 = 1" : all_conditions.join("\n and ")
|
74
|
+
end
|
72
75
|
|
73
76
|
{
|
74
77
|
filter_string: filter_string,
|