grape-listing 2.0.0.pre.beta.3 → 2.0.0.pre.beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/grape_listing/version.rb +1 -1
- data/lib/listing_service/search.rb +38 -7
- 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: 77d58fbe9510c3ff0cbf2f70b4f4b87a8988259d698b6bebb5af37a04aa298f2
|
4
|
+
data.tar.gz: de6a723a92e0247428961bd914c003f4b32decc9079652edf6dd3559957161d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f8c09ef3ff82bc903f9c0ae198ecdf50cd229b42d2edb1244b49c166ec093e1434c6bfcc8279dccd92a8bbf6d27cf1d5dba082709cdca508ffcdcc656f4ddf5
|
7
|
+
data.tar.gz: 7b68865cd1ab76d04b8d33b4a94bc14dafc0ed82dd35d4eda459f05550356f980d323366359679febda0470b48f2c30d39491d71f363a0c45f03d0370ce43fa5
|
@@ -30,7 +30,7 @@ module GrapeListing
|
|
30
30
|
next unless [column, condition, operator].all?
|
31
31
|
|
32
32
|
# применение кастомного скоупа (при наличии)
|
33
|
-
custom_scope = @custom_search[column]
|
33
|
+
custom_scope = @custom_search[column] if @custom_search
|
34
34
|
if custom_scope
|
35
35
|
@objects = list.send(custom_scope, value)
|
36
36
|
next
|
@@ -49,6 +49,8 @@ module GrapeListing
|
|
49
49
|
date_clause(subject, condition, operator, value)
|
50
50
|
when :boolean
|
51
51
|
boolean_clause(subject, condition, operator, value)
|
52
|
+
when :enum
|
53
|
+
enum_clause(subject, condition, operator, value)
|
52
54
|
end
|
53
55
|
|
54
56
|
# применение запроса для фильтрации
|
@@ -120,6 +122,15 @@ module GrapeListing
|
|
120
122
|
end
|
121
123
|
end
|
122
124
|
|
125
|
+
def enum_clause(subject, condition, operator, value)
|
126
|
+
case operator
|
127
|
+
when EQUAL
|
128
|
+
enum_equal(subject, condition, value)
|
129
|
+
when IN
|
130
|
+
enum_in(subject, condition, value)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
123
134
|
def string_present(subject, condition)
|
124
135
|
case condition
|
125
136
|
when IS
|
@@ -132,9 +143,9 @@ module GrapeListing
|
|
132
143
|
def string_contain(subject, condition, value)
|
133
144
|
case condition
|
134
145
|
when IS
|
135
|
-
"#{subject} ILIKE %#{value}%"
|
146
|
+
"#{subject} ILIKE '%#{value}%'"
|
136
147
|
when NOT
|
137
|
-
"#{subject} NOT ILIKE %#{value}%"
|
148
|
+
"#{subject} NOT ILIKE '%#{value}%'"
|
138
149
|
end
|
139
150
|
end
|
140
151
|
|
@@ -150,18 +161,18 @@ module GrapeListing
|
|
150
161
|
def string_start(subject, condition, value)
|
151
162
|
case condition
|
152
163
|
when IS
|
153
|
-
"#{subject} ILIKE #{value}%"
|
164
|
+
"#{subject} ILIKE '#{value}%'"
|
154
165
|
when NOT
|
155
|
-
"#{subject} NOT ILIKE #{value}%"
|
166
|
+
"#{subject} NOT ILIKE '#{value}%'"
|
156
167
|
end
|
157
168
|
end
|
158
169
|
|
159
170
|
def string_end(subject, condition, value)
|
160
171
|
case condition
|
161
172
|
when IS
|
162
|
-
"#{subject} ILIKE %#{value}"
|
173
|
+
"#{subject} ILIKE '%#{value}'"
|
163
174
|
when NOT
|
164
|
-
"#{subject} NOT ILIKE %#{value}"
|
175
|
+
"#{subject} NOT ILIKE '%#{value}'"
|
165
176
|
end
|
166
177
|
end
|
167
178
|
|
@@ -312,5 +323,25 @@ module GrapeListing
|
|
312
323
|
end
|
313
324
|
end
|
314
325
|
|
326
|
+
def enum_equal(subject, condition, value)
|
327
|
+
case condition
|
328
|
+
when IS
|
329
|
+
"#{subject} = '#{value}'"
|
330
|
+
when NOT
|
331
|
+
"#{subject} != '#{value}'"
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
def enum_in(subject, condition, value)
|
336
|
+
opts = value.map { |i| "'#{i}'" }.join(',')
|
337
|
+
|
338
|
+
case condition
|
339
|
+
when IS
|
340
|
+
"#{subject} IN (#{opts})"
|
341
|
+
when NOT
|
342
|
+
"#{subject} NOT IN (#{opts})"
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
315
346
|
end
|
316
347
|
end
|