arel_extensions 1.3.4 → 2.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +2 -1
  3. data/.rubocop.yml +4 -31
  4. data/.travis/oracle/download.js +152 -0
  5. data/.travis/oracle/download.sh +30 -0
  6. data/.travis/oracle/download_ojdbc.js +116 -0
  7. data/.travis/oracle/install.sh +34 -0
  8. data/.travis/setup_accounts.sh +9 -0
  9. data/.travis/sqlite3/extension-functions.sh +6 -0
  10. data/.travis.yml +223 -0
  11. data/Gemfile +21 -16
  12. data/README.md +14 -125
  13. data/Rakefile +30 -41
  14. data/TODO +1 -0
  15. data/appveyor.yml +44 -0
  16. data/arel_extensions.gemspec +14 -14
  17. data/functions.html +3 -3
  18. data/gemfiles/rails3.gemfile +10 -10
  19. data/gemfiles/rails4.gemfile +14 -14
  20. data/gemfiles/rails5_0.gemfile +14 -14
  21. data/gemfiles/rails5_1_4.gemfile +14 -14
  22. data/gemfiles/rails5_2.gemfile +14 -15
  23. data/init/mssql.sql +4 -4
  24. data/init/mysql.sql +38 -38
  25. data/init/oracle.sql +0 -0
  26. data/init/postgresql.sql +21 -21
  27. data/init/sqlite.sql +0 -0
  28. data/lib/arel_extensions/attributes.rb +3 -4
  29. data/lib/arel_extensions/boolean_functions.rb +14 -53
  30. data/lib/arel_extensions/common_sql_functions.rb +16 -15
  31. data/lib/arel_extensions/comparators.rb +28 -27
  32. data/lib/arel_extensions/date_duration.rb +14 -13
  33. data/lib/arel_extensions/insert_manager.rb +15 -18
  34. data/lib/arel_extensions/math.rb +44 -31
  35. data/lib/arel_extensions/math_functions.rb +39 -46
  36. data/lib/arel_extensions/nodes/abs.rb +1 -0
  37. data/lib/arel_extensions/nodes/blank.rb +2 -1
  38. data/lib/arel_extensions/nodes/case.rb +16 -16
  39. data/lib/arel_extensions/nodes/cast.rb +6 -8
  40. data/lib/arel_extensions/nodes/ceil.rb +1 -1
  41. data/lib/arel_extensions/nodes/coalesce.rb +3 -2
  42. data/lib/arel_extensions/nodes/collate.rb +10 -9
  43. data/lib/arel_extensions/nodes/concat.rb +18 -9
  44. data/lib/arel_extensions/nodes/date_diff.rb +22 -38
  45. data/lib/arel_extensions/nodes/duration.rb +3 -0
  46. data/lib/arel_extensions/nodes/find_in_set.rb +1 -0
  47. data/lib/arel_extensions/nodes/floor.rb +1 -1
  48. data/lib/arel_extensions/nodes/format.rb +8 -35
  49. data/lib/arel_extensions/nodes/formatted_number.rb +23 -22
  50. data/lib/arel_extensions/nodes/function.rb +37 -42
  51. data/lib/arel_extensions/nodes/is_null.rb +0 -0
  52. data/lib/arel_extensions/nodes/json.rb +39 -48
  53. data/lib/arel_extensions/nodes/length.rb +0 -5
  54. data/lib/arel_extensions/nodes/levenshtein_distance.rb +1 -1
  55. data/lib/arel_extensions/nodes/locate.rb +1 -0
  56. data/lib/arel_extensions/nodes/log10.rb +2 -1
  57. data/lib/arel_extensions/nodes/matches.rb +7 -5
  58. data/lib/arel_extensions/nodes/md5.rb +1 -0
  59. data/lib/arel_extensions/nodes/power.rb +5 -5
  60. data/lib/arel_extensions/nodes/rand.rb +1 -0
  61. data/lib/arel_extensions/nodes/repeat.rb +4 -2
  62. data/lib/arel_extensions/nodes/replace.rb +8 -16
  63. data/lib/arel_extensions/nodes/round.rb +6 -5
  64. data/lib/arel_extensions/nodes/soundex.rb +15 -15
  65. data/lib/arel_extensions/nodes/std.rb +21 -18
  66. data/lib/arel_extensions/nodes/substring.rb +16 -8
  67. data/lib/arel_extensions/nodes/trim.rb +5 -3
  68. data/lib/arel_extensions/nodes/union.rb +8 -5
  69. data/lib/arel_extensions/nodes/union_all.rb +7 -4
  70. data/lib/arel_extensions/nodes/wday.rb +4 -0
  71. data/lib/arel_extensions/nodes.rb +1 -1
  72. data/lib/arel_extensions/null_functions.rb +7 -5
  73. data/lib/arel_extensions/predications.rb +43 -44
  74. data/lib/arel_extensions/railtie.rb +5 -5
  75. data/lib/arel_extensions/set_functions.rb +7 -5
  76. data/lib/arel_extensions/string_functions.rb +29 -58
  77. data/lib/arel_extensions/tasks.rb +6 -6
  78. data/lib/arel_extensions/version.rb +1 -1
  79. data/lib/arel_extensions/visitors/ibm_db.rb +31 -24
  80. data/lib/arel_extensions/visitors/mssql.rb +184 -269
  81. data/lib/arel_extensions/visitors/mysql.rb +206 -271
  82. data/lib/arel_extensions/visitors/oracle.rb +175 -191
  83. data/lib/arel_extensions/visitors/oracle12.rb +31 -18
  84. data/lib/arel_extensions/visitors/postgresql.rb +170 -244
  85. data/lib/arel_extensions/visitors/sqlite.rb +124 -138
  86. data/lib/arel_extensions/visitors/to_sql.rb +237 -269
  87. data/lib/arel_extensions/visitors.rb +59 -75
  88. data/lib/arel_extensions.rb +31 -149
  89. data/test/database.yml +7 -15
  90. data/test/helper.rb +18 -0
  91. data/test/real_db_test.rb +113 -102
  92. data/test/support/fake_record.rb +3 -3
  93. data/test/test_comparators.rb +17 -14
  94. data/test/visitors/test_bulk_insert_oracle.rb +10 -10
  95. data/test/visitors/test_bulk_insert_sqlite.rb +12 -11
  96. data/test/visitors/test_bulk_insert_to_sql.rb +12 -10
  97. data/test/visitors/test_oracle.rb +55 -55
  98. data/test/visitors/test_to_sql.rb +226 -419
  99. data/test/with_ar/all_agnostic_test.rb +357 -567
  100. data/test/with_ar/insert_agnostic_test.rb +19 -25
  101. data/test/with_ar/test_bulk_sqlite.rb +15 -16
  102. data/test/with_ar/test_math_sqlite.rb +26 -26
  103. data/test/with_ar/test_string_mysql.rb +33 -31
  104. data/test/with_ar/test_string_sqlite.rb +34 -30
  105. metadata +23 -29
  106. data/.github/workflows/ruby.yml +0 -389
  107. data/gemfiles/rails6.gemfile +0 -29
  108. data/gemfiles/rails6_1.gemfile +0 -29
  109. data/gemfiles/rails7.gemfile +0 -22
  110. data/gemspecs/arel_extensions-v1.gemspec +0 -28
  111. data/gemspecs/arel_extensions-v2.gemspec +0 -28
  112. data/generate_gems.sh +0 -15
  113. data/lib/arel_extensions/aliases.rb +0 -14
  114. data/lib/arel_extensions/helpers.rb +0 -51
  115. data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
  116. data/lib/arel_extensions/nodes/sum.rb +0 -7
  117. data/lib/arel_extensions/visitors/convert_format.rb +0 -37
  118. data/test/arelx_test_helper.rb +0 -71
  119. data/version_v1.rb +0 -3
  120. data/version_v2.rb +0 -3
@@ -1,11 +1,11 @@
1
1
  module ArelExtensions
2
2
  module Nodes
3
3
  class Power < Function
4
- RETURN_TYPE = :number
5
-
6
- def initialize expr
7
- super [convert_to_node(expr.first), convert_to_number(expr[1])]
8
- end
4
+ RETURN_TYPE = :number
5
+
6
+ def initialize expr
7
+ super [convert_to_node(expr.first), convert_to_number(expr[1])]
8
+ end
9
9
  end
10
10
  end
11
11
  end
@@ -10,6 +10,7 @@ module ArelExtensions
10
10
  super []
11
11
  end
12
12
  end
13
+
13
14
  end
14
15
  end
15
16
  end
@@ -2,7 +2,7 @@ module ArelExtensions
2
2
  module Nodes
3
3
  class Repeat < Function
4
4
  RETURN_TYPE = :string
5
-
5
+
6
6
  def initialize expr
7
7
  tab = expr.map { |arg|
8
8
  convert_to_node(arg)
@@ -11,8 +11,10 @@ module ArelExtensions
11
11
  end
12
12
 
13
13
  def +(other)
14
- return ArelExtensions::Nodes::Concat.new(self.expressions + [other])
14
+ return ArelExtensions::Nodes::Concat.new(self.expressions + [other])
15
15
  end
16
+
16
17
  end
18
+
17
19
  end
18
20
  end
@@ -2,26 +2,18 @@ module ArelExtensions
2
2
  module Nodes
3
3
  class Replace < Function
4
4
  RETURN_TYPE = :string
5
- attr_accessor :left, :pattern, :substitute
6
5
 
7
- def initialize left, pattern, substitute
8
- @left = convert_to_node(left)
9
- @pattern = convert_to_node(pattern)
10
- @substitute = convert_to_node(substitute)
11
- super([@left, @pattern, @substitute])
6
+ def initialize expr
7
+ tab = expr.map { |arg|
8
+ convert_to_node(arg)
9
+ }
10
+ return super(tab)
12
11
  end
13
- end
14
-
15
- class RegexpReplace < Function
16
- RETURN_TYPE = :string
17
- attr_accessor :left, :pattern, :substitute
18
12
 
19
- def initialize left, pattern, substitute
20
- @left = convert_to_node(left)
21
- @pattern = (pattern.is_a?(Regexp) ? pattern : %r[#{pattern}])
22
- @substitute = convert_to_node(substitute)
23
- super([@left, @pattern, @substitute])
13
+ def +(other)
14
+ return ArelExtensions::Nodes::Concat.new(self.expressions + [other])
24
15
  end
16
+
25
17
  end
26
18
  end
27
19
  end
@@ -4,12 +4,13 @@ module ArelExtensions
4
4
  RETURN_TYPE = :number
5
5
 
6
6
  def initialize expr
7
- if expr && expr.length == 1
8
- super [convert_to_node(expr.first)]
9
- else
10
- super [convert_to_node(expr.first), convert_to_number(expr[1])]
11
- end
7
+ if expr && expr.length == 1
8
+ super [convert_to_node(expr.first)]
9
+ else
10
+ super [convert_to_node(expr.first), convert_to_number(expr[1])]
11
+ end
12
12
  end
13
+
13
14
  end
14
15
  end
15
16
  end
@@ -1,18 +1,18 @@
1
1
  module ArelExtensions
2
- module Nodes
3
- class Soundex < Function
4
- include Arel::Expressions
5
- include ArelExtensions::Comparators
2
+ module Nodes
3
+ class Soundex < Function
4
+ include Arel::Expressions
5
+ include ArelExtensions::Comparators
6
+
7
+ RETURN_TYPE = :string
8
+
9
+ def ==(other)
10
+ Arel::Nodes::Equality.new self, Arel::Nodes.build_quoted(other, self)
11
+ end
6
12
 
7
- RETURN_TYPE = :string
8
-
9
- def ==(other)
10
- Arel::Nodes::Equality.new self, Arel.quoted(other, self)
11
- end
12
-
13
- def !=(other)
14
- Arel::Nodes::NotEqual.new self, Arel.quoted(other, self)
15
- end
16
- end
17
- end
13
+ def !=(other)
14
+ Arel::Nodes::NotEqual.new self, Arel::Nodes.build_quoted(other, self)
15
+ end
16
+ end
17
+ end
18
18
  end
@@ -1,23 +1,26 @@
1
1
  module ArelExtensions
2
2
  module Nodes
3
- class Std < AggregateFunction
4
- RETURN_TYPE = :number
5
- attr_accessor :unbiased_estimator
6
-
7
- def initialize node, **opts
8
- @unbiased_estimator = opts[:unbiased] ? true : false
9
- super node, **opts
10
- end
11
- end
12
-
13
- class Variance < AggregateFunction
14
- RETURN_TYPE = :number
15
- attr_accessor :unbiased_estimator
16
-
17
- def initialize node, **opts
18
- @unbiased_estimator = opts[:unbiased] ? true : false
19
- super node, **opts
20
- end
3
+ class Std < Function
4
+ RETURN_TYPE = :number
5
+
6
+ attr_accessor :unbiased_estimator
7
+ def initialize expr
8
+ col = expr.first
9
+ @unbiased_estimator = expr[1]
10
+ super [col]
11
+ end
21
12
  end
13
+
14
+ class Variance < Function
15
+ RETURN_TYPE = :number
16
+
17
+ attr_accessor :unbiased_estimator
18
+ def initialize expr
19
+ col = expr.first
20
+ @unbiased_estimator = expr[1]
21
+ super [col]
22
+ end
23
+ end
24
+
22
25
  end
23
26
  end
@@ -1,15 +1,23 @@
1
1
  module ArelExtensions
2
2
  module Nodes
3
3
  class Substring < Function
4
- RETURN_TYPE = :string
4
+ RETURN_TYPE = :string
5
+
6
+ def initialize expr
7
+ tab = [convert_to_node(expr[0]), convert_to_node(expr[1])]
8
+ if expr[2]
9
+ tab << convert_to_node(expr[2])
10
+ # else
11
+ # tab << expr[0].length
12
+ end
13
+ return super(tab)
14
+ end
15
+
16
+ # def +(other)
17
+ # puts "[Substring] : #{other.inspect} (#{self.expressions.inspect})"
18
+ # return ArelExtensions::Nodes::Concat.new(self.expressions + [other])
19
+ # end
5
20
 
6
- def initialize expr
7
- tab = [convert_to_node(expr[0]), convert_to_node(expr[1])]
8
- if expr[2]
9
- tab << convert_to_node(expr[2])
10
- end
11
- return super(tab)
12
- end
13
21
  end
14
22
  end
15
23
  end
@@ -2,7 +2,7 @@ module ArelExtensions
2
2
  module Nodes
3
3
  class Trim < Function
4
4
  RETURN_TYPE = :string
5
-
5
+
6
6
  def initialize expr
7
7
  tab = expr.map { |arg|
8
8
  convert_to_node(arg)
@@ -11,16 +11,18 @@ module ArelExtensions
11
11
  end
12
12
 
13
13
  def +(other)
14
- return ArelExtensions::Nodes::Concat.new(self.expressions + [other])
14
+ return ArelExtensions::Nodes::Concat.new(self.expressions + [other])
15
15
  end
16
+
16
17
  end
17
18
 
18
19
  class Ltrim < Trim
19
- RETURN_TYPE = :string
20
+ RETURN_TYPE = :string
20
21
  end
21
22
 
22
23
  class Rtrim < Trim
23
24
  RETURN_TYPE = :string
24
25
  end
26
+
25
27
  end
26
28
  end
@@ -1,21 +1,24 @@
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
+
5
+ def initialize left,right
6
+ return super(left,right)
6
7
  end
7
8
 
8
9
  def +(other)
9
- return ArelExtensions::Nodes::Union.new(self, other)
10
+ return ArelExtensions::Nodes::Union.new(self,other)
10
11
  end
11
12
 
12
13
  def union(other)
13
- return ArelExtensions::Nodes::UnionAll.new(self, other)
14
+ return ArelExtensions::Nodes::UnionAll.new(self,other)
14
15
  end
15
16
 
16
17
  def as other
17
- Arel::Nodes::TableAlias.new Arel.grouping(self), Arel::Nodes::SqlLiteral.new(other.to_s)
18
+ Arel::Nodes::TableAlias.new Arel::Nodes::Grouping.new(self), Arel::Nodes::SqlLiteral.new(other.to_s)
18
19
  end
19
20
  end
21
+
20
22
  end
21
23
  end
24
+
@@ -1,17 +1,20 @@
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
+
5
+ def initialize left,right
6
+ return super(left,right)
6
7
  end
7
8
 
8
9
  def union_all(other)
9
- return ArelExtensions::Nodes::UnionAll.new(self, other)
10
+ return ArelExtensions::Nodes::UnionAll.new(self,other)
10
11
  end
11
12
 
12
13
  def as other
13
- Arel::Nodes::TableAlias.new Arel.grouping(self), Arel::Nodes::SqlLiteral.new(other.to_s)
14
+ Arel::Nodes::TableAlias.new Arel::Nodes::Grouping.new(self), Arel::Nodes::SqlLiteral.new(other.to_s)
14
15
  end
15
16
  end
17
+
16
18
  end
17
19
  end
20
+
@@ -1,15 +1,19 @@
1
1
  module ArelExtensions
2
2
  module Nodes
3
3
  class Wday < Function
4
+
5
+
4
6
  def initialize other, aliaz = nil
5
7
  tab = Array.new
6
8
  tab << other
7
9
  super(tab, aliaz)
8
10
  end
9
11
 
12
+
10
13
  def date
11
14
  @expressions.first
12
15
  end
16
+
13
17
  end
14
18
  end
15
19
  end
@@ -1,2 +1,2 @@
1
1
  require 'arel_extensions/nodes/function'
2
- require 'arel_extensions/nodes/aggregate_function'
2
+
@@ -3,21 +3,23 @@ require 'arel_extensions/nodes/is_null'
3
3
 
4
4
  module ArelExtensions
5
5
  module NullFunctions
6
- # ISNULL function lets you return an alternative value when an expression is NULL.
6
+
7
+ #ISNULL function lets you return an alternative value when an expression is NULL.
7
8
  def is_null
8
9
  ArelExtensions::Nodes::IsNull.new [self]
9
10
  end
10
-
11
- # ISNOTNULL function lets you return an alternative value when an expression is NOT NULL.
11
+
12
+ #ISNOTNULL function lets you return an alternative value when an expression is NOT NULL.
12
13
  def is_not_null
13
14
  ArelExtensions::Nodes::IsNotNull.new [self]
14
15
  end
15
-
16
+
16
17
  # returns the first non-null expr in the expression list. You must specify at least two expressions.
17
- # If all occurrences of expr evaluate to null, then the function returns null.
18
+ #If all occurrences of expr evaluate to null, then the function returns null.
18
19
  def coalesce *args
19
20
  args.unshift(self)
20
21
  ArelExtensions::Nodes::Coalesce.new args
21
22
  end
23
+
22
24
  end
23
25
  end
@@ -1,78 +1,76 @@
1
1
  module ArelExtensions
2
2
  module Predications
3
- def when right, expression = nil
4
- ArelExtensions::Nodes::Case.new(self).when(right, expression)
3
+ def when right, expression=nil
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.quoted(other), escape)
9
+ Arel::Nodes::Matches.new(self, Arel::Nodes.build_quoted(other), escape)
10
10
  else
11
- Arel::Nodes::Matches.new(self, Arel.quoted(other), escape, case_sensitive)
11
+ Arel::Nodes::Matches.new(self, Arel::Nodes.build_quoted(other), escape, case_sensitive)
12
12
  end
13
13
  end
14
14
 
15
- def imatches(other, escape = nil)
15
+ def imatches(other, escape=nil)
16
16
  ArelExtensions::Nodes::IMatches.new(self, other, escape)
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
- def in(*other) # In should handle nil element in the Array
24
- other = other.first if other.length <= 1
23
+ def in(other) #In should handle nil element in the Array
25
24
  case other
26
25
  when Range
27
26
  self.between(other)
28
- when Arel::Nodes::Grouping, ArelExtensions::Nodes::Union, ArelExtensions::Nodes::UnionAll
29
- Arel::Nodes::In.new(self, quoted_node(other))
30
27
  when Enumerable
31
- nils, values = other.partition{ |v| v.nil? }
32
- ranges, values = values.partition{ |v| v.is_a?(Range) || v.is_a?(Arel::SelectManager)}
33
- # In order of (imagined) decreasing efficiency: nil, values, and then more complex.
34
- clauses =
35
- nils.uniq.map { |r| self.in(r) } \
36
- + (case values.uniq.size
37
- when 0 then []
38
- when 1 then [values[0].is_a?(Arel::Nodes::Grouping) ? self.in(values[0]) : self.eq(values[0])]
39
- else [Arel::Nodes::In.new(self, quoted_array(values))] end) \
40
- + ranges.uniq.map { |r| self.in(r) }
41
- clauses.empty? ? Arel.false : clauses.reduce(&:or)
28
+ if other.include?(nil)
29
+ other.delete(nil)
30
+ case other.length
31
+ when 0
32
+ self.is_null
33
+ when 1
34
+ self.is_null.or(self==other[0])
35
+ else
36
+ self.is_null.or(Arel::Nodes::In.new(self,quoted_array(other)))
37
+ end
38
+ else
39
+ Arel::Nodes::In.new(self,quoted_array(other))
40
+ end
42
41
  when nil
43
42
  self.is_null
44
43
  when Arel::SelectManager
45
44
  Arel::Nodes::In.new(self, other.ast)
46
45
  else
47
- Arel::Nodes::In.new(self, quoted_node(other))
46
+ Arel::Nodes::In.new(self,quoted_node(other))
48
47
  end
49
48
  end
50
49
 
51
- def not_in(*other) # In should handle nil element in the Array
52
- other = other.first if other.length <= 1
50
+ def not_in(other) #In should handle nil element in the Array
53
51
  case other
54
52
  when Range
55
53
  Arel::Nodes::Not.new(self.between(other))
56
- when Arel::Nodes::Grouping, ArelExtensions::Nodes::Union, ArelExtensions::Nodes::UnionAll
57
- Arel::Nodes::NotIn.new(self, quoted_node(other))
58
54
  when Enumerable
59
- nils, values = other.partition{ |v| v.nil? }
60
- ranges, values = values.partition{ |v| v.is_a?(Range) || v.is_a?(Arel::SelectManager)}
61
- # In order of (imagined) decreasing efficiency: nil, values, and then more complex.
62
- clauses =
63
- nils.uniq.map { |r| self.not_in(r) } \
64
- + (case values.uniq.size
65
- when 0 then []
66
- when 1 then [values[0].is_a?(Arel::Nodes::Grouping) ? self.not_in(values[0]) : self.not_eq(values[0])]
67
- else [Arel::Nodes::NotIn.new(self, quoted_array(values))] end) \
68
- + ranges.uniq.map { |r| self.not_in(r) }
69
- Arel::Nodes::And.new clauses
55
+ if other.include?(nil)
56
+ other.delete(nil)
57
+ case other.length
58
+ when 0
59
+ self.is_not_null
60
+ when 1
61
+ self.is_not_null.and(self!=other[0])
62
+ else
63
+ self.is_not_null.and(Arel::Nodes::NotIn.new(self,quoted_array(other)))
64
+ end
65
+ else
66
+ Arel::Nodes::NotIn.new(self,quoted_array(other))
67
+ end
70
68
  when nil
71
69
  self.is_not_null
72
70
  when Arel::SelectManager
73
71
  Arel::Nodes::NotIn.new(self, other.ast)
74
72
  else
75
- Arel::Nodes::NotIn.new(self, quoted_node(other))
73
+ Arel::Nodes::NotIn.new(self,quoted_node(other))
76
74
  end
77
75
  end
78
76
 
@@ -81,20 +79,21 @@ module ArelExtensions
81
79
  when Arel::Attributes::Attribute, Arel::Nodes::Node, Integer
82
80
  object
83
81
  when DateTime
84
- Arel.quoted(object, self)
82
+ Arel::Nodes.build_quoted(object, self)
85
83
  when Time
86
- Arel.quoted(object.strftime('%H:%M:%S'), self)
84
+ Arel::Nodes.build_quoted(object.strftime('%H:%M:%S'), self)
87
85
  when String
88
- Arel.quoted(object)
86
+ Arel::Nodes.build_quoted(object)
89
87
  when Date
90
- Arel.quoted(object.to_s, self)
88
+ Arel::Nodes.build_quoted(object.to_s, self)
91
89
  when NilClass
92
90
  Arel.sql('NULL')
93
91
  when ActiveSupport::Duration
94
92
  object.to_i
95
93
  else
96
- raise(ArgumentError, "#{object.class} cannot be converted to CONCAT arg")
94
+ raise(ArgumentError, "#{object.class} can not be converted to CONCAT arg")
97
95
  end
98
96
  end
97
+
99
98
  end
100
99
  end
@@ -1,9 +1,9 @@
1
1
  require 'rails'
2
2
 
3
3
  module ArelExtensions
4
- class Railtie < Rails::Railtie
5
- rake_tasks do
6
- load 'arel_extensions/tasks.rb'
7
- end
8
- end
4
+ class Railtie < Rails::Railtie
5
+ rake_tasks do
6
+ load 'arel_extensions/tasks.rb'
7
+ end
8
+ end
9
9
  end
@@ -3,28 +3,30 @@ require 'arel_extensions/nodes/union_all'
3
3
 
4
4
  module ArelExtensions
5
5
  module SetFunctions
6
+
6
7
  def +(other)
7
- ArelExtensions::Nodes::Union.new(self, other)
8
+ ArelExtensions::Nodes::Union.new(self,other)
8
9
  end
9
10
 
10
11
  def union(other)
11
- ArelExtensions::Nodes::Union.new(self, other)
12
+ ArelExtensions::Nodes::Union.new(self,other)
12
13
  end
13
14
 
14
15
  def union_all(other)
15
- ArelExtensions::Nodes::UnionAll.new(self, other)
16
+ ArelExtensions::Nodes::UnionAll.new(self,other)
16
17
  end
17
18
 
18
19
  def uniq
19
20
  self
20
21
  end
22
+
21
23
  end
22
24
  end
23
25
 
24
- class Arel::Nodes::Union
26
+ Arel::Nodes::Union.class_eval do
25
27
  include ArelExtensions::SetFunctions
26
28
  end
27
29
 
28
- class Arel::Nodes::UnionAll
30
+ Arel::Nodes::UnionAll.class_eval do
29
31
  include ArelExtensions::SetFunctions
30
32
  end