effective_resources 0.3.9 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0fa62c577020ee87d607427cf4910492d2437db
4
- data.tar.gz: 710ec9d60171463f8e153d2525cdf66698ae9847
3
+ metadata.gz: adee85d1da92d005ebe0329f1b977aab11944ee0
4
+ data.tar.gz: d2f0a66e76368a937d7a7d57690635177b63ed50
5
5
  SHA512:
6
- metadata.gz: c5d6c31a8f02deb548467e65dfaacbdc107216f33f4a63d2d71e2f415bc8c9d9c1f7674e63dfe651da7ece1e43a8871296fa760fc682190485ade203b2e4b06f
7
- data.tar.gz: 404375d92f1b6675c61540856eb2ec0b210a076e2d1444085d081e9abe6ac0f87bc7ec8e6fca6d19a956e3d88b59b0966b9404b5953a47a3d51f67c027dbef97
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
- klass = (class_name.safe_constantize rescue nil)
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(postgres? ? "#{sql_column} IS NULL ASC" : "ISNULL(#{sql_column}) ASC")
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((("ISNULL(#{sql_column}}), ") if mysql?).to_s + "#{sql_column}='' ASC, #{sql_column} #{sql_direction}" + (" NULLS LAST" if postgres?))
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((("ISNULL(#{sql_column}}), ") if mysql?).to_s + "#{sql_column} #{sql_direction}" + (" NULLS LAST" if postgres?))
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("#{sql_column} IS NULL")
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '0.3.9'.freeze
2
+ VERSION = '0.3.10'.freeze
3
3
  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.9
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-05-31 00:00:00.000000000 Z
11
+ date: 2017-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails