effective_resources 0.3.9 → 0.3.10
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adee85d1da92d005ebe0329f1b977aab11944ee0
|
4
|
+
data.tar.gz: d2f0a66e76368a937d7a7d57690635177b63ed50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2fcab634cdafa892b22bbe8e7a86f5ad982d20a8a8548a364226362de5a80dab216e26ad392c0ff600ce3a43fb085d759f0d4d8e10f9790fc86857cb1703b9d
|
7
|
+
data.tar.gz: d2ddcb29d2dff7a536f4c83d978afbadc69d2ae839fee7826371e59f247f0c8f3be50d460e839c0d116cf910844c4ae666564445f4ab52d56c2f1d55eed03901
|
@@ -36,7 +36,8 @@ module Effective
|
|
36
36
|
|
37
37
|
0.upto(names.length-1) do |index|
|
38
38
|
class_name = (names[index..-1].map { |name| name.classify } * '::')
|
39
|
-
|
39
|
+
|
40
|
+
klass = class_name.safe_constantize
|
40
41
|
|
41
42
|
if klass.present?
|
42
43
|
@namespaces = names[0...index]
|
@@ -21,7 +21,7 @@ module Effective
|
|
21
21
|
case sql_type
|
22
22
|
when :belongs_to
|
23
23
|
relation
|
24
|
-
.order(
|
24
|
+
.order("#{is_null(sql_column)} ASC")
|
25
25
|
.order(order_by_associated_conditions(association, sort: sort, direction: direction))
|
26
26
|
when :belongs_to_polymorphic
|
27
27
|
relation
|
@@ -39,10 +39,10 @@ module Effective
|
|
39
39
|
relation.order("#{sql_column(:roles_mask)} #{sql_direction}")
|
40
40
|
when :string, :text
|
41
41
|
relation
|
42
|
-
.order((
|
42
|
+
.order(("ISNULL(#{sql_column}), " if mysql?).to_s + "#{sql_column}='' ASC, #{sql_column} #{sql_direction}" + (" NULLS LAST" if postgres?).to_s)
|
43
43
|
else
|
44
44
|
relation
|
45
|
-
.order((
|
45
|
+
.order(("ISNULL(#{sql_column}), " if mysql?).to_s + "#{sql_column} #{sql_direction}" + (" NULLS LAST" if postgres?).to_s)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -63,7 +63,7 @@ module Effective
|
|
63
63
|
|
64
64
|
# term == 'nil' rescue false is a Rails 4.1 fix, where you can't compare a TimeWithZone to 'nil'
|
65
65
|
if (term == 'nil' rescue false) && ![:has_and_belongs_to_many, :has_many, :has_one, :belongs_to_polymorphic, :effective_roles].include?(sql_type)
|
66
|
-
return relation.where(
|
66
|
+
return relation.where(is_null(sql_column))
|
67
67
|
end
|
68
68
|
|
69
69
|
case sql_type
|
@@ -96,6 +96,10 @@ module Effective
|
|
96
96
|
@ilike ||= (postgres? ? 'ILIKE' : 'LIKE') # Only Postgres supports ILIKE, Mysql and Sqlite3 use LIKE
|
97
97
|
end
|
98
98
|
|
99
|
+
def is_null(sql_column)
|
100
|
+
mysql? == true ? "ISNULL(#{sql_column})" : "#{sql_column} IS NULL"
|
101
|
+
end
|
102
|
+
|
99
103
|
end
|
100
104
|
end
|
101
105
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|