pattern_query_helper 0.1.3 → 0.1.4
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/sorting.rb +12 -2
- data/lib/pattern_query_helper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00f3d3a35d3c3e1123335893dce1b17183837755
|
4
|
+
data.tar.gz: 9501bcba0adb2f201071cf838bbbf8b96a0fd78c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bde00eec48f1826ef48947c52ebe0bac4c1f7c8c3050e9adfdddbfbfc0a096cfc4b43a0bb8e879be8109f2482e7fa394a6f839d991264e0ff60456dc0dc21e27
|
7
|
+
data.tar.gz: 9d668688ad2f803a8316c9efcca8522eed6bada340dea22a7afcd05eb596eb8ff9b955b6f05146850168f9e55a306ea4e8995f185f16d3b953e35a937f7eafd2
|
data/Gemfile.lock
CHANGED
@@ -5,7 +5,11 @@ module PatternQueryHelper
|
|
5
5
|
if params[:sort]
|
6
6
|
sorts = params[:sort].split(",")
|
7
7
|
sorts.each_with_index do |sort, index|
|
8
|
-
|
8
|
+
column = sort.split(":")[0]
|
9
|
+
direction = sort.split(":")[1]
|
10
|
+
modifier = sort.split(":")[2]
|
11
|
+
|
12
|
+
if direction == "desc"
|
9
13
|
case PatternQueryHelper.active_record_adapter
|
10
14
|
when "sqlite3"
|
11
15
|
direction = "desc"
|
@@ -15,7 +19,13 @@ module PatternQueryHelper
|
|
15
19
|
else
|
16
20
|
direction = "asc"
|
17
21
|
end
|
18
|
-
|
22
|
+
|
23
|
+
case modifier
|
24
|
+
when "lowercase"
|
25
|
+
column = "lower(#{column})"
|
26
|
+
end
|
27
|
+
|
28
|
+
sort_sql << "#{column} #{direction}"
|
19
29
|
end
|
20
30
|
end
|
21
31
|
sort_sql.join(", ")
|