arel_extensions 2.1.3 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +1 -2
  3. data/.github/workflows/ruby.yml +4 -4
  4. data/.rubocop.yml +25 -1
  5. data/Gemfile +10 -10
  6. data/README.md +1 -2
  7. data/Rakefile +4 -4
  8. data/TODO +0 -1
  9. data/arel_extensions.gemspec +11 -11
  10. data/gemfiles/rails3.gemfile +10 -10
  11. data/gemfiles/rails4.gemfile +13 -13
  12. data/gemfiles/rails5_0.gemfile +12 -12
  13. data/gemfiles/rails5_1_4.gemfile +12 -12
  14. data/gemfiles/rails5_2.gemfile +13 -13
  15. data/gemfiles/rails6.gemfile +11 -11
  16. data/gemfiles/rails6_1.gemfile +11 -11
  17. data/gemfiles/rails7.gemfile +7 -7
  18. data/gemspecs/arel_extensions-v1.gemspec +12 -12
  19. data/gemspecs/arel_extensions-v2.gemspec +11 -11
  20. data/init/mssql.sql +0 -0
  21. data/init/mysql.sql +0 -0
  22. data/init/oracle.sql +0 -0
  23. data/init/postgresql.sql +0 -0
  24. data/init/sqlite.sql +0 -0
  25. data/lib/arel_extensions/attributes.rb +2 -2
  26. data/lib/arel_extensions/boolean_functions.rb +2 -4
  27. data/lib/arel_extensions/common_sql_functions.rb +10 -10
  28. data/lib/arel_extensions/comparators.rb +14 -14
  29. data/lib/arel_extensions/date_duration.rb +7 -7
  30. data/lib/arel_extensions/helpers.rb +16 -13
  31. data/lib/arel_extensions/insert_manager.rb +1 -1
  32. data/lib/arel_extensions/math.rb +16 -18
  33. data/lib/arel_extensions/math_functions.rb +18 -18
  34. data/lib/arel_extensions/nodes/abs.rb +0 -0
  35. data/lib/arel_extensions/nodes/aggregate_function.rb +0 -0
  36. data/lib/arel_extensions/nodes/blank.rb +1 -1
  37. data/lib/arel_extensions/nodes/case.rb +4 -6
  38. data/lib/arel_extensions/nodes/cast.rb +3 -3
  39. data/lib/arel_extensions/nodes/ceil.rb +0 -0
  40. data/lib/arel_extensions/nodes/change_case.rb +0 -0
  41. data/lib/arel_extensions/nodes/coalesce.rb +0 -0
  42. data/lib/arel_extensions/nodes/collate.rb +9 -9
  43. data/lib/arel_extensions/nodes/concat.rb +2 -2
  44. data/lib/arel_extensions/nodes/date_diff.rb +6 -6
  45. data/lib/arel_extensions/nodes/duration.rb +0 -0
  46. data/lib/arel_extensions/nodes/find_in_set.rb +0 -0
  47. data/lib/arel_extensions/nodes/floor.rb +0 -0
  48. data/lib/arel_extensions/nodes/format.rb +0 -0
  49. data/lib/arel_extensions/nodes/formatted_number.rb +2 -2
  50. data/lib/arel_extensions/nodes/function.rb +21 -21
  51. data/lib/arel_extensions/nodes/is_null.rb +0 -0
  52. data/lib/arel_extensions/nodes/json.rb +7 -7
  53. data/lib/arel_extensions/nodes/length.rb +0 -0
  54. data/lib/arel_extensions/nodes/levenshtein_distance.rb +1 -1
  55. data/lib/arel_extensions/nodes/locate.rb +0 -0
  56. data/lib/arel_extensions/nodes/log10.rb +0 -0
  57. data/lib/arel_extensions/nodes/matches.rb +1 -1
  58. data/lib/arel_extensions/nodes/md5.rb +0 -0
  59. data/lib/arel_extensions/nodes/power.rb +0 -0
  60. data/lib/arel_extensions/nodes/rand.rb +0 -0
  61. data/lib/arel_extensions/nodes/repeat.rb +0 -0
  62. data/lib/arel_extensions/nodes/replace.rb +2 -2
  63. data/lib/arel_extensions/nodes/round.rb +0 -0
  64. data/lib/arel_extensions/nodes/soundex.rb +2 -2
  65. data/lib/arel_extensions/nodes/std.rb +0 -0
  66. data/lib/arel_extensions/nodes/substring.rb +0 -0
  67. data/lib/arel_extensions/nodes/sum.rb +0 -0
  68. data/lib/arel_extensions/nodes/then.rb +0 -0
  69. data/lib/arel_extensions/nodes/trim.rb +0 -0
  70. data/lib/arel_extensions/nodes/union.rb +4 -4
  71. data/lib/arel_extensions/nodes/union_all.rb +3 -3
  72. data/lib/arel_extensions/nodes/wday.rb +0 -0
  73. data/lib/arel_extensions/nodes.rb +0 -0
  74. data/lib/arel_extensions/null_functions.rb +0 -0
  75. data/lib/arel_extensions/predications.rb +10 -10
  76. data/lib/arel_extensions/railtie.rb +1 -1
  77. data/lib/arel_extensions/set_functions.rb +3 -3
  78. data/lib/arel_extensions/string_functions.rb +8 -8
  79. data/lib/arel_extensions/tasks.rb +2 -2
  80. data/lib/arel_extensions/version.rb +1 -1
  81. data/lib/arel_extensions/visitors/convert_format.rb +0 -0
  82. data/lib/arel_extensions/visitors/ibm_db.rb +19 -19
  83. data/lib/arel_extensions/visitors/mssql.rb +127 -121
  84. data/lib/arel_extensions/visitors/mysql.rb +137 -145
  85. data/lib/arel_extensions/visitors/oracle.rb +128 -128
  86. data/lib/arel_extensions/visitors/oracle12.rb +16 -16
  87. data/lib/arel_extensions/visitors/postgresql.rb +139 -137
  88. data/lib/arel_extensions/visitors/sqlite.rb +83 -85
  89. data/lib/arel_extensions/visitors/to_sql.rb +143 -148
  90. data/lib/arel_extensions/visitors.rb +7 -7
  91. data/lib/arel_extensions.rb +46 -32
  92. data/test/arelx_test_helper.rb +14 -13
  93. data/test/database.yml +5 -5
  94. data/test/real_db_test.rb +78 -78
  95. data/test/support/fake_record.rb +1 -1
  96. data/test/test_comparators.rb +5 -5
  97. data/test/visitors/test_bulk_insert_oracle.rb +4 -4
  98. data/test/visitors/test_bulk_insert_sqlite.rb +4 -4
  99. data/test/visitors/test_bulk_insert_to_sql.rb +4 -4
  100. data/test/visitors/test_oracle.rb +14 -14
  101. data/test/visitors/test_to_sql.rb +82 -82
  102. data/test/with_ar/all_agnostic_test.rb +364 -299
  103. data/test/with_ar/insert_agnostic_test.rb +17 -14
  104. data/test/with_ar/test_bulk_sqlite.rb +4 -4
  105. data/test/with_ar/test_math_sqlite.rb +12 -12
  106. data/test/with_ar/test_string_mysql.rb +20 -20
  107. data/test/with_ar/test_string_sqlite.rb +20 -20
  108. data/version_v1.rb +1 -1
  109. data/version_v2.rb +1 -1
  110. metadata +2 -9
  111. data/.travis/oracle/download.js +0 -152
  112. data/.travis/oracle/download.sh +0 -30
  113. data/.travis/oracle/download_ojdbc.js +0 -116
  114. data/.travis/oracle/install.sh +0 -34
  115. data/.travis/setup_accounts.sh +0 -9
  116. data/.travis/sqlite3/extension-functions.sh +0 -6
  117. data/.travis.yml +0 -193
@@ -22,14 +22,14 @@ module ArelExtensions
22
22
 
23
23
  def as other
24
24
  res = Arel::Nodes::As.new(self.clone, Arel.sql(other))
25
- if Gem::Version.new(Arel::VERSION) >= Gem::Version.new("9.0.0")
25
+ if Gem::Version.new(Arel::VERSION) >= Gem::Version.new('9.0.0')
26
26
  self.alias = Arel.sql(other)
27
27
  end
28
28
  res
29
29
  end
30
30
 
31
31
  def expr
32
- @expressions.first
32
+ @expressions.first
33
33
  end
34
34
 
35
35
  def left
@@ -41,17 +41,17 @@ module ArelExtensions
41
41
  end
42
42
 
43
43
  def ==(other)
44
- Arel::Nodes::Equality.new self, Arel::Nodes.build_quoted(other, self)
44
+ Arel::Nodes::Equality.new self, Arel.quoted(other, self)
45
45
  end
46
46
 
47
47
  def !=(other)
48
- Arel::Nodes::NotEqual.new self, Arel::Nodes.build_quoted(other, self)
48
+ Arel::Nodes::NotEqual.new self, Arel.quoted(other, self)
49
49
  end
50
50
 
51
51
  def type_of_attribute(att)
52
52
  case att
53
53
  when Arel::Attributes::Attribute
54
- ArelExtensions::column_of(att.relation.table_name, att.name.to_s)&.type || att
54
+ Arel.column_of(att.relation.table_name, att.name.to_s)&.type || att
55
55
  when ArelExtensions::Nodes::Function
56
56
  att.return_type
57
57
  # else
@@ -64,13 +64,13 @@ module ArelExtensions
64
64
  when Arel::Attributes::Attribute, Arel::Nodes::Node, Integer
65
65
  object
66
66
  when DateTime
67
- Arel::Nodes.build_quoted(object, self)
67
+ Arel.quoted(object, self)
68
68
  when Time
69
- Arel::Nodes.build_quoted(object.strftime('%H:%M:%S'), self)
69
+ Arel.quoted(object.strftime('%H:%M:%S'), self)
70
70
  when MBSTRING, String, Symbol
71
- Arel::Nodes.build_quoted(object.to_s)
71
+ Arel.quoted(object.to_s)
72
72
  when Date
73
- Arel::Nodes.build_quoted(object.to_s, self)
73
+ Arel.quoted(object.to_s, self)
74
74
  when NilClass
75
75
  Arel.sql('NULL')
76
76
  when ActiveSupport::Duration
@@ -87,7 +87,7 @@ module ArelExtensions
87
87
  when Arel::Nodes::Node
88
88
  object
89
89
  when Integer
90
- Arel::Nodes.build_quoted(object.to_s)
90
+ Arel.quoted(object.to_s)
91
91
  when Arel::Attributes::Attribute
92
92
  case self.type_of_attribute(object)
93
93
  when :date
@@ -98,17 +98,17 @@ module ArelExtensions
98
98
  object
99
99
  end
100
100
  when DateTime
101
- Arel::Nodes.build_quoted(object, self)
101
+ Arel.quoted(object, self)
102
102
  when Time
103
- Arel::Nodes.build_quoted(object.strftime('%H:%M:%S'), self)
103
+ Arel.quoted(object.strftime('%H:%M:%S'), self)
104
104
  when MBSTRING, String
105
- Arel::Nodes.build_quoted(object.to_s)
105
+ Arel.quoted(object.to_s)
106
106
  when Date
107
- Arel::Nodes.build_quoted(object, self)
107
+ Arel.quoted(object, self)
108
108
  when NilClass
109
109
  Arel.sql(nil)
110
110
  when ActiveSupport::Duration
111
- Arel::Nodes.build_quoted(object.to_i.to_s)
111
+ Arel.quoted(object.to_i.to_s)
112
112
  else
113
113
  raise(ArgumentError, "#{object.class} cannot be converted to CONCAT arg")
114
114
  end
@@ -119,11 +119,11 @@ module ArelExtensions
119
119
  when Arel::Attributes::Attribute, Arel::Nodes::Node
120
120
  object
121
121
  when DateTime, Time
122
- Arel::Nodes.build_quoted(Date.new(object.year, object.month, object.day), self)
122
+ Arel.quoted(Date.new(object.year, object.month, object.day), self)
123
123
  when MBSTRING, String
124
- Arel::Nodes.build_quoted(Date.parse(object.to_s), self)
124
+ Arel.quoted(Date.parse(object.to_s), self)
125
125
  when Date
126
- Arel::Nodes.build_quoted(object, self)
126
+ Arel.quoted(object, self)
127
127
  else
128
128
  raise(ArgumentError, "#{object.class} cannot be converted to Date")
129
129
  end
@@ -134,11 +134,11 @@ module ArelExtensions
134
134
  when Arel::Attributes::Attribute, Arel::Nodes::Node
135
135
  object
136
136
  when DateTime, Time
137
- Arel::Nodes.build_quoted(object, self)
137
+ Arel.quoted(object, self)
138
138
  when MBSTRING, String
139
- Arel::Nodes.build_quoted(Time.parse(object.to_s), self)
139
+ Arel.quoted(Time.parse(object.to_s), self)
140
140
  when Date
141
- Arel::Nodes.build_quoted(Time.utc(object.year, object.month, object.day, 0, 0, 0), self)
141
+ Arel.quoted(Time.utc(object.year, object.month, object.day, 0, 0, 0), self)
142
142
  else
143
143
  raise(ArgumentError, "#{object.class} cannot be converted to Datetime")
144
144
  end
File without changes
@@ -11,15 +11,15 @@ module ArelExtensions
11
11
  end
12
12
 
13
13
  def get key
14
- JsonGet.new(self,key)
14
+ JsonGet.new(self, key)
15
15
  end
16
16
 
17
17
  def set key, value
18
- JsonSet.new(self,key,value)
18
+ JsonSet.new(self, key, value)
19
19
  end
20
20
 
21
21
  def group as_array = true, orders = nil
22
- JsonGroup.new(self,as_array, orders)
22
+ JsonGroup.new(self, as_array, orders)
23
23
  end
24
24
 
25
25
  def hash
@@ -32,19 +32,19 @@ module ArelExtensions
32
32
  n.dict
33
33
  when Array
34
34
  n.map{|e|
35
- (e.is_a?(Array) || e.is_a?(Hash)) ? Json.new(e) : convert_to_json_node(e)
35
+ (e.is_a?(Array) || e.is_a?(Hash)) ? Json.new(e) : convert_to_json_node(e)
36
36
  }
37
37
  when Hash
38
- n.reduce({}){|acc,v|
38
+ n.reduce({}){|acc, v|
39
39
  acc[convert_to_json_node(v[0])] = (v[1].is_a?(Array) || v[1].is_a?(Hash)) ? Json.new(v[1]) : convert_to_json_node(v[1])
40
40
  acc
41
41
  }
42
42
  when String, Numeric, TrueClass, FalseClass
43
43
  convert_to_node(n)
44
44
  when Date
45
- convert_to_node(n.strftime("%Y-%m-%d"))
45
+ convert_to_node(n.strftime('%Y-%m-%d'))
46
46
  when DateTime, Time
47
- convert_to_node(n.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"))
47
+ convert_to_node(n.strftime('%Y-%m-%dT%H:%M:%S.%L%:z'))
48
48
  when NilClass
49
49
  Arel.null
50
50
  when Arel::SelectManager
File without changes
@@ -4,7 +4,7 @@ module ArelExtensions
4
4
  RETURN_TYPE = :number
5
5
 
6
6
  def initialize expr
7
- super [convert_to_node(expr.first), Arel::Nodes.build_quoted(expr[1])]
7
+ super [convert_to_node(expr.first), Arel.quoted(expr[1])]
8
8
  end
9
9
  end
10
10
  end
File without changes
File without changes
@@ -4,7 +4,7 @@ module ArelExtensions
4
4
  attr_accessor :case_sensitive if Arel::VERSION.to_i < 7
5
5
 
6
6
  def initialize(left, right, escape = nil)
7
- r = Arel::Nodes.build_quoted(right)
7
+ r = Arel.quoted(right)
8
8
  if Arel::VERSION.to_i < 7 # managed by default in version 7+ (rails 5), so useful for rails 3 & 4
9
9
  super(left, r, escape)
10
10
  @case_sensitive = false
File without changes
File without changes
File without changes
File without changes
@@ -8,7 +8,7 @@ module ArelExtensions
8
8
  @left = convert_to_node(left)
9
9
  @pattern = convert_to_node(pattern)
10
10
  @substitute = convert_to_node(substitute)
11
- super([@left,@pattern,@substitute])
11
+ super([@left, @pattern, @substitute])
12
12
  end
13
13
  end
14
14
 
@@ -20,7 +20,7 @@ module ArelExtensions
20
20
  @left = convert_to_node(left)
21
21
  @pattern = (pattern.is_a?(Regexp) ? pattern : %r[#{pattern}])
22
22
  @substitute = convert_to_node(substitute)
23
- super([@left,@pattern,@substitute])
23
+ super([@left, @pattern, @substitute])
24
24
  end
25
25
  end
26
26
  end
File without changes
@@ -7,11 +7,11 @@ module ArelExtensions
7
7
  RETURN_TYPE = :string
8
8
 
9
9
  def ==(other)
10
- Arel::Nodes::Equality.new self, Arel::Nodes.build_quoted(other, self)
10
+ Arel::Nodes::Equality.new self, Arel.quoted(other, self)
11
11
  end
12
12
 
13
13
  def !=(other)
14
- Arel::Nodes::NotEqual.new self, Arel::Nodes.build_quoted(other, self)
14
+ Arel::Nodes::NotEqual.new self, Arel.quoted(other, self)
15
15
  end
16
16
  end
17
17
  end
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,16 +1,16 @@
1
1
  module ArelExtensions
2
2
  module Nodes
3
3
  class Union < Arel::Nodes::Union
4
- def initialize left,right
5
- return super(left,right)
4
+ def initialize left, right
5
+ return super(left, right)
6
6
  end
7
7
 
8
8
  def +(other)
9
- return ArelExtensions::Nodes::Union.new(self,other)
9
+ return ArelExtensions::Nodes::Union.new(self, other)
10
10
  end
11
11
 
12
12
  def union(other)
13
- return ArelExtensions::Nodes::UnionAll.new(self,other)
13
+ return ArelExtensions::Nodes::UnionAll.new(self, other)
14
14
  end
15
15
 
16
16
  def as other
@@ -1,12 +1,12 @@
1
1
  module ArelExtensions
2
2
  module Nodes
3
3
  class UnionAll < Arel::Nodes::UnionAll
4
- def initialize left,right
5
- return super(left,right)
4
+ def initialize left, right
5
+ return super(left, right)
6
6
  end
7
7
 
8
8
  def union_all(other)
9
- return ArelExtensions::Nodes::UnionAll.new(self,other)
9
+ return ArelExtensions::Nodes::UnionAll.new(self, other)
10
10
  end
11
11
 
12
12
  def as other
File without changes
File without changes
File without changes
@@ -1,14 +1,14 @@
1
1
  module ArelExtensions
2
2
  module Predications
3
3
  def when right, expression = nil
4
- ArelExtensions::Nodes::Case.new(self).when(right,expression)
4
+ ArelExtensions::Nodes::Case.new(self).when(right, expression)
5
5
  end
6
6
 
7
- def matches(other, escape = nil,case_sensitive = nil)
7
+ def matches(other, escape = nil, case_sensitive = nil)
8
8
  if Arel::VERSION.to_i < 7
9
- Arel::Nodes::Matches.new(self, Arel::Nodes.build_quoted(other), escape)
9
+ Arel::Nodes::Matches.new(self, Arel.quoted(other), escape)
10
10
  else
11
- Arel::Nodes::Matches.new(self, Arel::Nodes.build_quoted(other), escape, case_sensitive)
11
+ Arel::Nodes::Matches.new(self, Arel.quoted(other), escape, case_sensitive)
12
12
  end
13
13
  end
14
14
 
@@ -17,7 +17,7 @@ module ArelExtensions
17
17
  end
18
18
 
19
19
  def cast right
20
- ArelExtensions::Nodes::Cast.new([self,right])
20
+ ArelExtensions::Nodes::Cast.new([self, right])
21
21
  end
22
22
 
23
23
  def in(*other) # In should handle nil element in the Array
@@ -72,7 +72,7 @@ module ArelExtensions
72
72
  when Arel::SelectManager
73
73
  Arel::Nodes::NotIn.new(self, other.ast)
74
74
  else
75
- Arel::Nodes::NotIn.new(self,quoted_node(other))
75
+ Arel::Nodes::NotIn.new(self, quoted_node(other))
76
76
  end
77
77
  end
78
78
 
@@ -81,13 +81,13 @@ module ArelExtensions
81
81
  when Arel::Attributes::Attribute, Arel::Nodes::Node, Integer
82
82
  object
83
83
  when DateTime
84
- Arel::Nodes.build_quoted(object, self)
84
+ Arel.quoted(object, self)
85
85
  when Time
86
- Arel::Nodes.build_quoted(object.strftime('%H:%M:%S'), self)
86
+ Arel.quoted(object.strftime('%H:%M:%S'), self)
87
87
  when String
88
- Arel::Nodes.build_quoted(object)
88
+ Arel.quoted(object)
89
89
  when Date
90
- Arel::Nodes.build_quoted(object.to_s, self)
90
+ Arel.quoted(object.to_s, self)
91
91
  when NilClass
92
92
  Arel.sql('NULL')
93
93
  when ActiveSupport::Duration
@@ -3,7 +3,7 @@ require 'rails'
3
3
  module ArelExtensions
4
4
  class Railtie < Rails::Railtie
5
5
  rake_tasks do
6
- load 'arel_extensions/tasks.rb'
6
+ load 'arel_extensions/tasks.rb'
7
7
  end
8
8
  end
9
9
  end
@@ -4,15 +4,15 @@ require 'arel_extensions/nodes/union_all'
4
4
  module ArelExtensions
5
5
  module SetFunctions
6
6
  def +(other)
7
- ArelExtensions::Nodes::Union.new(self,other)
7
+ ArelExtensions::Nodes::Union.new(self, other)
8
8
  end
9
9
 
10
10
  def union(other)
11
- ArelExtensions::Nodes::Union.new(self,other)
11
+ ArelExtensions::Nodes::Union.new(self, other)
12
12
  end
13
13
 
14
14
  def union_all(other)
15
- ArelExtensions::Nodes::UnionAll.new(self,other)
15
+ ArelExtensions::Nodes::UnionAll.new(self, other)
16
16
  end
17
17
 
18
18
  def uniq
@@ -101,27 +101,27 @@ module ArelExtensions
101
101
  end
102
102
 
103
103
  def ai_matches other # accent insensitive & case sensitive
104
- ArelExtensions::Nodes::AiMatches.new(self,other)
104
+ ArelExtensions::Nodes::AiMatches.new(self, other)
105
105
  end
106
106
 
107
107
  def ai_imatches other # accent insensitive & case insensitive
108
- ArelExtensions::Nodes::AiIMatches.new(self,other)
108
+ ArelExtensions::Nodes::AiIMatches.new(self, other)
109
109
  end
110
110
 
111
111
  def smatches other # accent sensitive & case sensitive
112
- ArelExtensions::Nodes::SMatches.new(self,other)
112
+ ArelExtensions::Nodes::SMatches.new(self, other)
113
113
  end
114
114
 
115
115
  def ai_collate
116
- ArelExtensions::Nodes::Collate.new(self,nil,true,false)
116
+ ArelExtensions::Nodes::Collate.new(self, nil, true, false)
117
117
  end
118
118
 
119
119
  def ci_collate
120
- ArelExtensions::Nodes::Collate.new(self,nil,false,true)
120
+ ArelExtensions::Nodes::Collate.new(self, nil, false, true)
121
121
  end
122
122
 
123
- def collate ai = false,ci = false, option = nil
124
- ArelExtensions::Nodes::Collate.new(self,option,ai,ci)
123
+ def collate ai = false, ci = false, option = nil
124
+ ArelExtensions::Nodes::Collate.new(self, option, ai, ci)
125
125
  end
126
126
 
127
127
  # REPLACE function replaces a sequence of characters in a string with another set of characters, not case-sensitive.
@@ -144,7 +144,7 @@ module ArelExtensions
144
144
  # concat elements of a group, separated by sep and ordered by a list of Ascending or Descending
145
145
  def group_concat(sep = nil, *orders, group: nil, order: nil)
146
146
  if orders.present?
147
- warn("Warning : ArelExtensions: group_concat: you should now use the kwarg 'order' to specify an order in the group_concat.")
147
+ warn("Warning: ArelExtensions: group_concat: you should now use the kwarg 'order' to specify an order in the group_concat.")
148
148
  end
149
149
  order_tabs = [orders].flatten.map{ |o|
150
150
  if o.is_a?(Arel::Nodes::Ascending) || o.is_a?(Arel::Nodes::Descending)
@@ -1,8 +1,8 @@
1
1
  namespace :arel_extensions do
2
2
  desc 'Install DB functions into current DB'
3
3
  task install_functions: :environment do
4
- @env_db = if ENV['DB'] == 'oracle' && ((defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx") || (RUBY_PLATFORM == 'java')) # not supported
5
- (RUBY_PLATFORM == 'java' ? "jdbc-sqlite" : 'sqlite')
4
+ @env_db = if ENV['DB'] == 'oracle' && ((defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx') || (RUBY_PLATFORM == 'java')) # not supported
5
+ (RUBY_PLATFORM == 'java' ? 'jdbc-sqlite' : 'sqlite')
6
6
  else
7
7
  ENV['DB'] || ActiveRecord::Base.connection.adapter_name
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "2.1.3".freeze
2
+ VERSION = '2.1.4'.freeze
3
3
  end
File without changes
@@ -2,45 +2,45 @@ module ArelExtensions
2
2
  module Visitors
3
3
  class Arel::Visitors::IBM_DB
4
4
  def visit_ArelExtensions_Nodes_Ceil o, collector
5
- collector << "CEILING("
5
+ collector << 'CEILING('
6
6
  collector = visit o.expr, collector
7
- collector << ")"
7
+ collector << ')'
8
8
  collector
9
9
  end
10
10
 
11
11
  def visit_ArelExtensions_Nodes_Trim o, collector
12
- collector << "LTRIM(RTRIM("
12
+ collector << 'LTRIM(RTRIM('
13
13
  o.expressions.each_with_index { |arg, i|
14
14
  collector << COMMA if i != 0
15
15
  collector = visit arg, collector
16
16
  }
17
- collector << "))"
17
+ collector << '))'
18
18
  collector
19
19
  end
20
20
 
21
21
  def visit_ArelExtensions_Nodes_DateDiff o, collector
22
- collector << "DAY("
22
+ collector << 'DAY('
23
23
  collector = visit o.left, collector
24
- collector << ","
24
+ collector << ','
25
25
  if o.right.is_a?(Arel::Attributes::Attribute)
26
26
  collector = visit o.right, collector
27
27
  else
28
28
  collector << "'#{o.right}'"
29
29
  end
30
- collector << ")"
30
+ collector << ')'
31
31
  collector
32
32
  end
33
33
 
34
34
  def visit_ArelExtensions_Nodes_Duration o, collector
35
35
  # visit left for period
36
- if o.left == "d"
37
- collector << "DAY("
38
- elsif o.left == "m"
39
- collector << "MONTH("
40
- elsif o.left == "w"
41
- collector << "WEEK"
42
- elsif o.left == "y"
43
- collector << "YEAR("
36
+ if o.left == 'd'
37
+ collector << 'DAY('
38
+ elsif o.left == 'm'
39
+ collector << 'MONTH('
40
+ elsif o.left == 'w'
41
+ collector << 'WEEK'
42
+ elsif o.left == 'y'
43
+ collector << 'YEAR('
44
44
  end
45
45
  # visit right
46
46
  if o.right.is_a?(Arel::Attributes::Attribute)
@@ -48,20 +48,20 @@ module ArelExtensions
48
48
  else
49
49
  collector << "'#{o.right}'"
50
50
  end
51
- collector << ")"
51
+ collector << ')'
52
52
  collector
53
53
  end
54
54
 
55
55
  def visit_ArelExtensions_Nodes_IsNull o, collector
56
- collector << "COALESCE("
56
+ collector << 'COALESCE('
57
57
  collector = visit o.left, collector
58
- collector << ","
58
+ collector << ','
59
59
  if (o.right.is_a?(Arel::Attributes::Attribute))
60
60
  collector = visit o.right, collector
61
61
  else
62
62
  collector << "'#{o.right}'"
63
63
  end
64
- collector << ")"
64
+ collector << ')'
65
65
  collector
66
66
  end
67
67
  end