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.
- checksums.yaml +4 -4
- data/.codeclimate.yml +2 -1
- data/.rubocop.yml +4 -31
- data/.travis/oracle/download.js +152 -0
- data/.travis/oracle/download.sh +30 -0
- data/.travis/oracle/download_ojdbc.js +116 -0
- data/.travis/oracle/install.sh +34 -0
- data/.travis/setup_accounts.sh +9 -0
- data/.travis/sqlite3/extension-functions.sh +6 -0
- data/.travis.yml +223 -0
- data/Gemfile +21 -16
- data/README.md +14 -125
- data/Rakefile +30 -41
- data/TODO +1 -0
- data/appveyor.yml +44 -0
- data/arel_extensions.gemspec +14 -14
- data/functions.html +3 -3
- data/gemfiles/rails3.gemfile +10 -10
- data/gemfiles/rails4.gemfile +14 -14
- data/gemfiles/rails5_0.gemfile +14 -14
- data/gemfiles/rails5_1_4.gemfile +14 -14
- data/gemfiles/rails5_2.gemfile +14 -15
- data/init/mssql.sql +4 -4
- data/init/mysql.sql +38 -38
- data/init/oracle.sql +0 -0
- data/init/postgresql.sql +21 -21
- data/init/sqlite.sql +0 -0
- data/lib/arel_extensions/attributes.rb +3 -4
- data/lib/arel_extensions/boolean_functions.rb +14 -53
- data/lib/arel_extensions/common_sql_functions.rb +16 -15
- data/lib/arel_extensions/comparators.rb +28 -27
- data/lib/arel_extensions/date_duration.rb +14 -13
- data/lib/arel_extensions/insert_manager.rb +15 -18
- data/lib/arel_extensions/math.rb +44 -31
- data/lib/arel_extensions/math_functions.rb +39 -46
- data/lib/arel_extensions/nodes/abs.rb +1 -0
- data/lib/arel_extensions/nodes/blank.rb +2 -1
- data/lib/arel_extensions/nodes/case.rb +16 -16
- data/lib/arel_extensions/nodes/cast.rb +6 -8
- data/lib/arel_extensions/nodes/ceil.rb +1 -1
- data/lib/arel_extensions/nodes/coalesce.rb +3 -2
- data/lib/arel_extensions/nodes/collate.rb +10 -9
- data/lib/arel_extensions/nodes/concat.rb +18 -9
- data/lib/arel_extensions/nodes/date_diff.rb +22 -38
- data/lib/arel_extensions/nodes/duration.rb +3 -0
- data/lib/arel_extensions/nodes/find_in_set.rb +1 -0
- data/lib/arel_extensions/nodes/floor.rb +1 -1
- data/lib/arel_extensions/nodes/format.rb +8 -35
- data/lib/arel_extensions/nodes/formatted_number.rb +23 -22
- data/lib/arel_extensions/nodes/function.rb +37 -42
- data/lib/arel_extensions/nodes/is_null.rb +0 -0
- data/lib/arel_extensions/nodes/json.rb +39 -48
- data/lib/arel_extensions/nodes/length.rb +0 -5
- data/lib/arel_extensions/nodes/levenshtein_distance.rb +1 -1
- data/lib/arel_extensions/nodes/locate.rb +1 -0
- data/lib/arel_extensions/nodes/log10.rb +2 -1
- data/lib/arel_extensions/nodes/matches.rb +7 -5
- data/lib/arel_extensions/nodes/md5.rb +1 -0
- data/lib/arel_extensions/nodes/power.rb +5 -5
- data/lib/arel_extensions/nodes/rand.rb +1 -0
- data/lib/arel_extensions/nodes/repeat.rb +4 -2
- data/lib/arel_extensions/nodes/replace.rb +8 -16
- data/lib/arel_extensions/nodes/round.rb +6 -5
- data/lib/arel_extensions/nodes/soundex.rb +15 -15
- data/lib/arel_extensions/nodes/std.rb +21 -18
- data/lib/arel_extensions/nodes/substring.rb +16 -8
- data/lib/arel_extensions/nodes/trim.rb +5 -3
- data/lib/arel_extensions/nodes/union.rb +8 -5
- data/lib/arel_extensions/nodes/union_all.rb +7 -4
- data/lib/arel_extensions/nodes/wday.rb +4 -0
- data/lib/arel_extensions/nodes.rb +1 -1
- data/lib/arel_extensions/null_functions.rb +7 -5
- data/lib/arel_extensions/predications.rb +43 -44
- data/lib/arel_extensions/railtie.rb +5 -5
- data/lib/arel_extensions/set_functions.rb +7 -5
- data/lib/arel_extensions/string_functions.rb +29 -58
- data/lib/arel_extensions/tasks.rb +6 -6
- data/lib/arel_extensions/version.rb +1 -1
- data/lib/arel_extensions/visitors/ibm_db.rb +31 -24
- data/lib/arel_extensions/visitors/mssql.rb +184 -269
- data/lib/arel_extensions/visitors/mysql.rb +206 -271
- data/lib/arel_extensions/visitors/oracle.rb +175 -191
- data/lib/arel_extensions/visitors/oracle12.rb +31 -18
- data/lib/arel_extensions/visitors/postgresql.rb +170 -244
- data/lib/arel_extensions/visitors/sqlite.rb +124 -138
- data/lib/arel_extensions/visitors/to_sql.rb +237 -269
- data/lib/arel_extensions/visitors.rb +59 -75
- data/lib/arel_extensions.rb +31 -149
- data/test/database.yml +7 -15
- data/test/helper.rb +18 -0
- data/test/real_db_test.rb +113 -102
- data/test/support/fake_record.rb +3 -3
- data/test/test_comparators.rb +17 -14
- data/test/visitors/test_bulk_insert_oracle.rb +10 -10
- data/test/visitors/test_bulk_insert_sqlite.rb +12 -11
- data/test/visitors/test_bulk_insert_to_sql.rb +12 -10
- data/test/visitors/test_oracle.rb +55 -55
- data/test/visitors/test_to_sql.rb +226 -419
- data/test/with_ar/all_agnostic_test.rb +357 -567
- data/test/with_ar/insert_agnostic_test.rb +19 -25
- data/test/with_ar/test_bulk_sqlite.rb +15 -16
- data/test/with_ar/test_math_sqlite.rb +26 -26
- data/test/with_ar/test_string_mysql.rb +33 -31
- data/test/with_ar/test_string_sqlite.rb +34 -30
- metadata +23 -29
- data/.github/workflows/ruby.yml +0 -389
- data/gemfiles/rails6.gemfile +0 -29
- data/gemfiles/rails6_1.gemfile +0 -29
- data/gemfiles/rails7.gemfile +0 -22
- data/gemspecs/arel_extensions-v1.gemspec +0 -28
- data/gemspecs/arel_extensions-v2.gemspec +0 -28
- data/generate_gems.sh +0 -15
- data/lib/arel_extensions/aliases.rb +0 -14
- data/lib/arel_extensions/helpers.rb +0 -51
- data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
- data/lib/arel_extensions/nodes/sum.rb +0 -7
- data/lib/arel_extensions/visitors/convert_format.rb +0 -37
- data/test/arelx_test_helper.rb +0 -71
- data/version_v1.rb +0 -3
- data/version_v2.rb +0 -3
@@ -1,11 +1,11 @@
|
|
1
1
|
module ArelExtensions
|
2
2
|
module Nodes
|
3
3
|
class Power < Function
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
@@ -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
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
super(
|
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
|
20
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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 <
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
5
|
-
|
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,
|
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,
|
14
|
+
return ArelExtensions::Nodes::UnionAll.new(self,other)
|
14
15
|
end
|
15
16
|
|
16
17
|
def as other
|
17
|
-
Arel::Nodes::TableAlias.new Arel.
|
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
|
-
|
5
|
-
|
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,
|
10
|
+
return ArelExtensions::Nodes::UnionAll.new(self,other)
|
10
11
|
end
|
11
12
|
|
12
13
|
def as other
|
13
|
-
Arel::Nodes::TableAlias.new Arel.
|
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,2 +1,2 @@
|
|
1
1
|
require 'arel_extensions/nodes/function'
|
2
|
-
|
2
|
+
|
@@ -3,21 +3,23 @@ require 'arel_extensions/nodes/is_null'
|
|
3
3
|
|
4
4
|
module ArelExtensions
|
5
5
|
module NullFunctions
|
6
|
-
|
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
|
-
#
|
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
|
-
#
|
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
|
4
|
-
ArelExtensions::Nodes::Case.new(self).when(right,
|
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
|
7
|
+
def matches(other, escape=nil,case_sensitive= nil)
|
8
8
|
if Arel::VERSION.to_i < 7
|
9
|
-
Arel::Nodes::Matches.new(self, Arel.
|
9
|
+
Arel::Nodes::Matches.new(self, Arel::Nodes.build_quoted(other), escape)
|
10
10
|
else
|
11
|
-
Arel::Nodes::Matches.new(self, Arel.
|
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
|
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,
|
20
|
+
ArelExtensions::Nodes::Cast.new([self,right])
|
21
21
|
end
|
22
22
|
|
23
|
-
def in(
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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,
|
46
|
+
Arel::Nodes::In.new(self,quoted_node(other))
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
|
-
def not_in(
|
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
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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,
|
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.
|
82
|
+
Arel::Nodes.build_quoted(object, self)
|
85
83
|
when Time
|
86
|
-
Arel.
|
84
|
+
Arel::Nodes.build_quoted(object.strftime('%H:%M:%S'), self)
|
87
85
|
when String
|
88
|
-
Arel.
|
86
|
+
Arel::Nodes.build_quoted(object)
|
89
87
|
when Date
|
90
|
-
Arel.
|
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}
|
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
|
@@ -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,
|
8
|
+
ArelExtensions::Nodes::Union.new(self,other)
|
8
9
|
end
|
9
10
|
|
10
11
|
def union(other)
|
11
|
-
ArelExtensions::Nodes::Union.new(self,
|
12
|
+
ArelExtensions::Nodes::Union.new(self,other)
|
12
13
|
end
|
13
14
|
|
14
15
|
def union_all(other)
|
15
|
-
ArelExtensions::Nodes::UnionAll.new(self,
|
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
|
-
|
26
|
+
Arel::Nodes::Union.class_eval do
|
25
27
|
include ArelExtensions::SetFunctions
|
26
28
|
end
|
27
29
|
|
28
|
-
|
30
|
+
Arel::Nodes::UnionAll.class_eval do
|
29
31
|
include ArelExtensions::SetFunctions
|
30
32
|
end
|