arel_extensions 1.2.23 → 2.0.0.rc3
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 +4 -4
- data/.rubocop.yml +4 -7
- data/.travis.yml +91 -61
- data/Gemfile +20 -15
- data/README.md +12 -17
- data/Rakefile +29 -40
- data/appveyor.yml +1 -1
- data/arel_extensions.gemspec +3 -3
- data/functions.html +3 -3
- data/gemfiles/rails3.gemfile +9 -9
- data/gemfiles/rails4.gemfile +13 -13
- data/gemfiles/rails5_0.gemfile +13 -13
- data/gemfiles/rails5_1_4.gemfile +13 -13
- data/gemfiles/rails5_2.gemfile +13 -13
- data/init/mssql.sql +4 -4
- data/init/mysql.sql +38 -38
- data/init/postgresql.sql +21 -21
- data/lib/arel_extensions.rb +19 -69
- data/lib/arel_extensions/attributes.rb +1 -0
- data/lib/arel_extensions/boolean_functions.rb +14 -55
- data/lib/arel_extensions/common_sql_functions.rb +8 -7
- data/lib/arel_extensions/comparators.rb +15 -14
- data/lib/arel_extensions/date_duration.rb +5 -4
- data/lib/arel_extensions/insert_manager.rb +16 -17
- data/lib/arel_extensions/math.rb +12 -11
- data/lib/arel_extensions/math_functions.rb +22 -29
- data/lib/arel_extensions/nodes.rb +1 -1
- data/lib/arel_extensions/nodes/abs.rb +1 -0
- data/lib/arel_extensions/nodes/blank.rb +1 -0
- data/lib/arel_extensions/nodes/case.rb +8 -11
- data/lib/arel_extensions/nodes/cast.rb +2 -4
- data/lib/arel_extensions/nodes/ceil.rb +1 -1
- data/lib/arel_extensions/nodes/change_case.rb +0 -0
- data/lib/arel_extensions/nodes/coalesce.rb +3 -2
- data/lib/arel_extensions/nodes/collate.rb +2 -1
- data/lib/arel_extensions/nodes/concat.rb +16 -7
- data/lib/arel_extensions/nodes/date_diff.rb +13 -10
- 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 -34
- data/lib/arel_extensions/nodes/formatted_number.rb +23 -22
- data/lib/arel_extensions/nodes/function.rb +16 -25
- data/lib/arel_extensions/nodes/json.rb +36 -43
- data/lib/arel_extensions/nodes/length.rb +1 -0
- data/lib/arel_extensions/nodes/levenshtein_distance.rb +0 -0
- 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 +6 -4
- 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 +6 -22
- 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/then.rb +0 -0
- data/lib/arel_extensions/nodes/trim.rb +5 -3
- data/lib/arel_extensions/nodes/union.rb +5 -2
- data/lib/arel_extensions/nodes/union_all.rb +3 -0
- data/lib/arel_extensions/nodes/wday.rb +4 -0
- data/lib/arel_extensions/null_functions.rb +7 -5
- data/lib/arel_extensions/predications.rb +34 -35
- data/lib/arel_extensions/railtie.rb +5 -5
- data/lib/arel_extensions/set_functions.rb +4 -2
- data/lib/arel_extensions/string_functions.rb +22 -43
- data/lib/arel_extensions/tasks.rb +5 -5
- data/lib/arel_extensions/version.rb +1 -1
- data/lib/arel_extensions/visitors.rb +60 -68
- data/lib/arel_extensions/visitors/ibm_db.rb +12 -5
- data/lib/arel_extensions/visitors/mssql.rb +57 -63
- data/lib/arel_extensions/visitors/mysql.rb +98 -149
- data/lib/arel_extensions/visitors/oracle.rb +68 -71
- data/lib/arel_extensions/visitors/oracle12.rb +15 -2
- data/lib/arel_extensions/visitors/postgresql.rb +63 -116
- data/lib/arel_extensions/visitors/sqlite.rb +70 -83
- data/lib/arel_extensions/visitors/to_sql.rb +109 -141
- data/test/database.yml +0 -2
- data/test/helper.rb +18 -0
- data/test/real_db_test.rb +43 -28
- data/test/support/fake_record.rb +2 -2
- data/test/test_comparators.rb +12 -9
- data/test/visitors/test_bulk_insert_oracle.rb +8 -8
- data/test/visitors/test_bulk_insert_sqlite.rb +10 -9
- data/test/visitors/test_bulk_insert_to_sql.rb +10 -8
- data/test/visitors/test_oracle.rb +42 -42
- data/test/visitors/test_to_sql.rb +196 -361
- data/test/with_ar/all_agnostic_test.rb +160 -195
- data/test/with_ar/insert_agnostic_test.rb +4 -3
- data/test/with_ar/test_bulk_sqlite.rb +9 -6
- data/test/with_ar/test_math_sqlite.rb +12 -8
- data/test/with_ar/test_string_mysql.rb +11 -5
- data/test/with_ar/test_string_sqlite.rb +12 -4
- metadata +11 -22
- data/.github/workflows/ruby.yml +0 -102
- data/gemfiles/rails6.gemfile +0 -30
- data/gemfiles/rails6_1.gemfile +0 -30
- 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/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 -26
- data/version_v1.rb +0 -3
- data/version_v2.rb +0 -3
@@ -1,2 +1,2 @@
|
|
1
1
|
require 'arel_extensions/nodes/function'
|
2
|
-
|
2
|
+
|
@@ -1,11 +1,7 @@
|
|
1
1
|
module ArelExtensions
|
2
2
|
module Nodes
|
3
|
-
if
|
3
|
+
if Arel::VERSION < "7.1.0"
|
4
4
|
class Case < Arel::Nodes::Node
|
5
|
-
include Arel::Expressions
|
6
|
-
include Arel::Math
|
7
|
-
include Arel::Predications
|
8
|
-
include Arel::OrderPredications
|
9
5
|
attr_accessor :case, :conditions, :default
|
10
6
|
|
11
7
|
def initialize expression = nil, default = nil
|
@@ -19,6 +15,7 @@ module ArelExtensions
|
|
19
15
|
|
20
16
|
class Else < Arel::Nodes::Unary # :nodoc:
|
21
17
|
end
|
18
|
+
|
22
19
|
end
|
23
20
|
else
|
24
21
|
class Case < Arel::Nodes::Case
|
@@ -29,10 +26,8 @@ module ArelExtensions
|
|
29
26
|
end
|
30
27
|
end
|
31
28
|
|
32
|
-
|
29
|
+
ArelExtensions::Nodes::Case.class_eval do
|
33
30
|
include Arel::Expressions
|
34
|
-
include Arel::Math
|
35
|
-
include Arel::Predications
|
36
31
|
include Arel::OrderPredications
|
37
32
|
include ArelExtensions::Math
|
38
33
|
include ArelExtensions::Comparators
|
@@ -46,6 +41,8 @@ module ArelExtensions
|
|
46
41
|
@conditions.last.right
|
47
42
|
elsif @default
|
48
43
|
@default.expr
|
44
|
+
else
|
45
|
+
nil
|
49
46
|
end
|
50
47
|
if obj.respond_to?(:return_type)
|
51
48
|
obj.return_type
|
@@ -95,9 +92,9 @@ module ArelExtensions
|
|
95
92
|
|
96
93
|
def eql? other
|
97
94
|
self.class == other.class &&
|
98
|
-
|
99
|
-
|
100
|
-
|
95
|
+
self.case == other.case &&
|
96
|
+
self.conditions == other.conditions &&
|
97
|
+
self.default == other.default
|
101
98
|
end
|
102
99
|
alias :== :eql?
|
103
100
|
|
@@ -14,10 +14,7 @@ module ArelExtensions
|
|
14
14
|
@return_type = :decimal
|
15
15
|
when :number
|
16
16
|
@return_type = :number
|
17
|
-
when 'char', 'varchar', 'nchar', 'nvarchar'
|
18
|
-
@return_type = :string
|
19
|
-
when 'text', :text, 'ntext', :ntext
|
20
|
-
@as_attr = expr[1].to_sym
|
17
|
+
when 'char', 'varchar', 'text', 'nchar', 'nvarchar', 'ntext'
|
21
18
|
@return_type = :string
|
22
19
|
when :datetime, 'datetime','smalldatetime'
|
23
20
|
@return_type = :datetime
|
@@ -49,6 +46,7 @@ module ArelExtensions
|
|
49
46
|
def return_type
|
50
47
|
@return_type
|
51
48
|
end
|
49
|
+
|
52
50
|
end
|
53
51
|
end
|
54
52
|
end
|
File without changes
|
@@ -2,7 +2,7 @@ module ArelExtensions
|
|
2
2
|
module Nodes
|
3
3
|
class Coalesce < Function
|
4
4
|
RETURN_TYPE = :string
|
5
|
-
|
5
|
+
|
6
6
|
attr_accessor :left_node_type
|
7
7
|
|
8
8
|
def return_type
|
@@ -20,7 +20,7 @@ module ArelExtensions
|
|
20
20
|
@left_node_type = :number
|
21
21
|
when ArelExtensions::Nodes::Coalesce, ArelExtensions::Nodes::Function
|
22
22
|
@left_node_type = expr.first.respond_to?(:left_node_type) ? expr.first.left_node_type : nil
|
23
|
-
when Arel::Nodes::Node, Arel::Attributes::Attribute
|
23
|
+
when Arel::Nodes::Node, Arel::Attributes::Attribute
|
24
24
|
@left_node_type = type_of_attribute(expr.first)
|
25
25
|
when Date
|
26
26
|
@left_node_type = :ruby_date
|
@@ -29,6 +29,7 @@ module ArelExtensions
|
|
29
29
|
end
|
30
30
|
return super(tab)
|
31
31
|
end
|
32
|
+
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -5,13 +5,14 @@ module ArelExtensions
|
|
5
5
|
|
6
6
|
attr_accessor :ai, :ci, :option
|
7
7
|
|
8
|
-
def initialize left, option
|
8
|
+
def initialize left, option=nil, ai=false, ci=false
|
9
9
|
@ai = ai
|
10
10
|
@ci = ci
|
11
11
|
@option = option
|
12
12
|
tab = [convert_to_node(left)]
|
13
13
|
return super(tab)
|
14
14
|
end
|
15
|
+
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -11,7 +11,7 @@ module ArelExtensions::Nodes
|
|
11
11
|
else
|
12
12
|
node
|
13
13
|
end
|
14
|
-
}.flatten.reduce([]) { |res, b|
|
14
|
+
}.flatten.reduce([]) { | res, b |
|
15
15
|
# concatenate successive literal strings.
|
16
16
|
if b.is_a?(Arel::Nodes::Quoted) && b.expr == ""
|
17
17
|
res
|
@@ -37,16 +37,25 @@ module ArelExtensions::Nodes
|
|
37
37
|
def concat(other)
|
38
38
|
Concat.new(self.expressions + [other])
|
39
39
|
end
|
40
|
+
|
40
41
|
end
|
41
42
|
|
42
|
-
class GroupConcat <
|
43
|
+
class GroupConcat < Function
|
43
44
|
RETURN_TYPE = :string
|
44
45
|
|
45
|
-
attr_accessor :
|
46
|
-
|
47
|
-
def initialize
|
48
|
-
|
49
|
-
|
46
|
+
attr_accessor :orders
|
47
|
+
|
48
|
+
def initialize expr
|
49
|
+
tab = expr.map { |arg|
|
50
|
+
if arg.is_a?(Array)
|
51
|
+
@orders = arg
|
52
|
+
nil
|
53
|
+
else
|
54
|
+
convert_to_node(arg)
|
55
|
+
end
|
56
|
+
}.compact
|
57
|
+
super(tab)
|
50
58
|
end
|
59
|
+
|
51
60
|
end
|
52
61
|
end
|
@@ -2,7 +2,7 @@ require 'date'
|
|
2
2
|
|
3
3
|
module ArelExtensions
|
4
4
|
module Nodes
|
5
|
-
class DateDiff < Function #
|
5
|
+
class DateDiff < Function #difference entre colonne date et date string/date
|
6
6
|
attr_accessor :left_node_type
|
7
7
|
attr_accessor :right_node_type
|
8
8
|
|
@@ -12,7 +12,7 @@ module ArelExtensions
|
|
12
12
|
res = []
|
13
13
|
col = expr.first
|
14
14
|
case col
|
15
|
-
when Arel::Nodes::Node, Arel::Attributes::Attribute
|
15
|
+
when Arel::Nodes::Node, Arel::Attributes::Attribute
|
16
16
|
@left_node_type = type_of_attribute(col)
|
17
17
|
when Date
|
18
18
|
@left_node_type = :ruby_date
|
@@ -21,7 +21,7 @@ module ArelExtensions
|
|
21
21
|
end
|
22
22
|
res << ([:date, :ruby_date].include?(@left_node_type) ? convert_to_date_node(col) : convert_to_datetime_node(col))
|
23
23
|
case expr[1]
|
24
|
-
when Arel::Nodes::Node, Arel::Attributes::Attribute
|
24
|
+
when Arel::Nodes::Node, Arel::Attributes::Attribute
|
25
25
|
@right_node_type = type_of_attribute(expr[1])
|
26
26
|
when Date
|
27
27
|
@right_node_type = :ruby_date
|
@@ -97,7 +97,7 @@ module ArelExtensions
|
|
97
97
|
v ||= self.expressions.last
|
98
98
|
if defined?(ActiveSupport::Duration) && ActiveSupport::Duration === v
|
99
99
|
if @date_type == :ruby_date
|
100
|
-
Arel.sql("(INTERVAL '1' DAY) * %s" % v.inspect.to_i)
|
100
|
+
Arel.sql("(INTERVAL '1' DAY) * %s" % v.inspect.to_i )
|
101
101
|
else
|
102
102
|
Arel.sql("(INTERVAL '1' SECOND) * %s" % v.to_i)
|
103
103
|
end
|
@@ -136,7 +136,7 @@ module ArelExtensions
|
|
136
136
|
if ArelExtensions::Nodes::Duration === v
|
137
137
|
v.with_interval = true
|
138
138
|
case v.left
|
139
|
-
when
|
139
|
+
when 'd','m','y'
|
140
140
|
Arel.sql('day')
|
141
141
|
when 'h','mn','s'
|
142
142
|
Arel.sql('second')
|
@@ -145,12 +145,13 @@ module ArelExtensions
|
|
145
145
|
else
|
146
146
|
Arel.sql(Arel::Visitors::MSSQL::DATE_MAPPING[v.left])
|
147
147
|
end
|
148
|
+
else
|
149
|
+
nil
|
148
150
|
end
|
149
151
|
end
|
150
152
|
end
|
151
153
|
|
152
154
|
private
|
153
|
-
|
154
155
|
def convert(object)
|
155
156
|
case object
|
156
157
|
when Arel::Attributes::Attribute, Arel::Nodes::Node, ActiveSupport::Duration
|
@@ -158,16 +159,16 @@ module ArelExtensions
|
|
158
159
|
when Integer
|
159
160
|
object.days
|
160
161
|
when DateTime, Time, Date
|
161
|
-
raise(ArgumentError, "#{object.class}
|
162
|
+
raise(ArgumentError, "#{object.class} can not be converted to Integer")
|
162
163
|
when String
|
163
164
|
Arel::Nodes.build_quoted(object)
|
164
165
|
else
|
165
|
-
raise(ArgumentError, "#{object.class}
|
166
|
+
raise(ArgumentError, "#{object.class} can not be converted to Integer")
|
166
167
|
end
|
167
168
|
end
|
168
169
|
end
|
169
170
|
|
170
|
-
class DateSub < Function #
|
171
|
+
class DateSub < Function #difference entre colonne date et date string/date
|
171
172
|
RETURN_TYPE = :integer
|
172
173
|
|
173
174
|
def initialize(expr)
|
@@ -184,10 +185,12 @@ module ArelExtensions
|
|
184
185
|
if defined?(ActiveSupport::Duration) && ActiveSupport::Duration === object
|
185
186
|
object.to_i
|
186
187
|
else
|
187
|
-
raise(ArgumentError, "#{object.class}
|
188
|
+
raise(ArgumentError, "#{object.class} can not be converted to Number")
|
188
189
|
end
|
189
190
|
end
|
190
191
|
end
|
192
|
+
|
191
193
|
end
|
194
|
+
|
192
195
|
end
|
193
196
|
end
|
@@ -1,41 +1,15 @@
|
|
1
|
-
require 'strscan'
|
2
|
-
|
3
1
|
module ArelExtensions
|
4
2
|
module Nodes
|
5
|
-
class Format < Function
|
3
|
+
class Format < Function
|
6
4
|
RETURN_TYPE = :string
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
# Address portability issues with some of the formats.
|
20
|
-
def convert_format(fmt)
|
21
|
-
s = StringScanner.new fmt
|
22
|
-
res = StringIO.new
|
23
|
-
while !s.eos?
|
24
|
-
res <<
|
25
|
-
case
|
26
|
-
when s.scan(/%D/) then '%m/%d/%y'
|
27
|
-
when s.scan(/%F/) then '%Y-%m-%d'
|
28
|
-
when s.scan(/%R/) then '%H:%M'
|
29
|
-
when s.scan(/%r/) then '%I:%M:%S %p'
|
30
|
-
when s.scan(/%T/) then '%H:%M:%S'
|
31
|
-
when s.scan(/%v/) then '%e-%b-%Y'
|
32
|
-
|
33
|
-
when s.scan(/[^%]+/) then s.matched
|
34
|
-
when s.scan(/./) then s.matched
|
35
|
-
end
|
36
|
-
end
|
37
|
-
res.string
|
38
|
-
end
|
6
|
+
attr_accessor :col_type, :iso_format
|
7
|
+
def initialize expr
|
8
|
+
col = expr.first
|
9
|
+
@iso_format = expr[1]
|
10
|
+
@col_type = type_of_attribute(col)
|
11
|
+
super [col, convert_to_string_node(@iso_format)]
|
12
|
+
end
|
39
13
|
end
|
40
14
|
end
|
41
15
|
end
|
@@ -1,24 +1,25 @@
|
|
1
1
|
module ArelExtensions
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
2
|
+
module Nodes
|
3
|
+
class FormattedNumber < Function
|
4
|
+
RETURN_TYPE = :string
|
5
|
+
|
6
|
+
attr_accessor :locale, :prefix, :suffix, :flags, :scientific_notation, :width,:precision, :type, :original_string
|
7
|
+
|
8
|
+
def initialize expr
|
9
|
+
# expr[1] = {:locale => 'fr_FR', :type => "e"/"f"/"d", :prefix => "$ ", :suffix => " %", :flags => " +-#0", :width => 5, :precision => 6}
|
10
|
+
col = expr.first
|
11
|
+
@locale = expr[1][:locale]
|
12
|
+
@prefix = expr[1][:prefix]
|
13
|
+
@suffix = expr[1][:suffix]
|
14
|
+
@width = expr[1][:width]
|
15
|
+
@precision = expr[1][:precision]
|
16
|
+
@type = expr[1][:type]
|
17
|
+
@flags = expr[1][:flags]
|
18
|
+
@scientific_notation = /[eE]/.match(expr[1][:type]) || false
|
19
|
+
@original_string = expr[1][:original_string]
|
20
|
+
super [col]
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
24
25
|
end
|
@@ -10,10 +10,6 @@ module ArelExtensions
|
|
10
10
|
|
11
11
|
RETURN_TYPE = :string # by default...
|
12
12
|
|
13
|
-
# Support multibyte string if they are available.
|
14
|
-
MBSTRING =
|
15
|
-
defined?(ActiveSupport::Multibyte::Chars) ? ActiveSupport::Multibyte::Chars : String
|
16
|
-
|
17
13
|
# overrides as to make new Node like AliasPredication
|
18
14
|
|
19
15
|
def return_type
|
@@ -21,11 +17,7 @@ module ArelExtensions
|
|
21
17
|
end
|
22
18
|
|
23
19
|
def as other
|
24
|
-
|
25
|
-
if Gem::Version.new(Arel::VERSION) >= Gem::Version.new("9.0.0")
|
26
|
-
self.alias = Arel.sql(other)
|
27
|
-
end
|
28
|
-
res
|
20
|
+
Arel::Nodes::As.new(self, Arel.sql(other))
|
29
21
|
end
|
30
22
|
|
31
23
|
def expr
|
@@ -58,8 +50,8 @@ module ArelExtensions
|
|
58
50
|
end
|
59
51
|
when ArelExtensions::Nodes::Function
|
60
52
|
att.return_type
|
61
|
-
|
62
|
-
|
53
|
+
# else
|
54
|
+
# nil
|
63
55
|
end
|
64
56
|
end
|
65
57
|
|
@@ -71,7 +63,7 @@ module ArelExtensions
|
|
71
63
|
Arel::Nodes.build_quoted(object, self)
|
72
64
|
when Time
|
73
65
|
Arel::Nodes.build_quoted(object.strftime('%H:%M:%S'), self)
|
74
|
-
when
|
66
|
+
when String, Symbol
|
75
67
|
Arel::Nodes.build_quoted(object.to_s)
|
76
68
|
when Date
|
77
69
|
Arel::Nodes.build_quoted(object.to_s, self)
|
@@ -79,10 +71,8 @@ module ArelExtensions
|
|
79
71
|
Arel.sql('NULL')
|
80
72
|
when ActiveSupport::Duration
|
81
73
|
Arel.sql(object.to_i)
|
82
|
-
when Array
|
83
|
-
Arel::Nodes::Grouping.new(object.map{|e| convert_to_node(e)})
|
84
74
|
else
|
85
|
-
raise(ArgumentError, "#{object.class}
|
75
|
+
raise(ArgumentError, "#{object.class} can not be converted to CONCAT arg")
|
86
76
|
end
|
87
77
|
end
|
88
78
|
|
@@ -105,8 +95,8 @@ module ArelExtensions
|
|
105
95
|
Arel::Nodes.build_quoted(object, self)
|
106
96
|
when Time
|
107
97
|
Arel::Nodes.build_quoted(object.strftime('%H:%M:%S'), self)
|
108
|
-
when
|
109
|
-
Arel::Nodes.build_quoted(object
|
98
|
+
when String
|
99
|
+
Arel::Nodes.build_quoted(object)
|
110
100
|
when Date
|
111
101
|
Arel::Nodes.build_quoted(object, self)
|
112
102
|
when NilClass
|
@@ -114,7 +104,7 @@ module ArelExtensions
|
|
114
104
|
when ActiveSupport::Duration
|
115
105
|
Arel::Nodes.build_quoted(object.to_i.to_s)
|
116
106
|
else
|
117
|
-
raise(ArgumentError, "#{object.class}
|
107
|
+
raise(ArgumentError, "#{object.class} can not be converted to CONCAT arg")
|
118
108
|
end
|
119
109
|
end
|
120
110
|
|
@@ -124,12 +114,12 @@ module ArelExtensions
|
|
124
114
|
object
|
125
115
|
when DateTime, Time
|
126
116
|
Arel::Nodes.build_quoted(Date.new(object.year, object.month, object.day), self)
|
127
|
-
when
|
128
|
-
Arel::Nodes.build_quoted(Date.parse(object
|
117
|
+
when String
|
118
|
+
Arel::Nodes.build_quoted(Date.parse(object), self)
|
129
119
|
when Date
|
130
120
|
Arel::Nodes.build_quoted(object, self)
|
131
121
|
else
|
132
|
-
raise(ArgumentError, "#{object.class}
|
122
|
+
raise(ArgumentError, "#{object.class} can not be converted to Date")
|
133
123
|
end
|
134
124
|
end
|
135
125
|
|
@@ -139,12 +129,12 @@ module ArelExtensions
|
|
139
129
|
object
|
140
130
|
when DateTime, Time
|
141
131
|
Arel::Nodes.build_quoted(object, self)
|
142
|
-
when
|
143
|
-
Arel::Nodes.build_quoted(Time.parse(object
|
132
|
+
when String
|
133
|
+
Arel::Nodes.build_quoted(Time.parse(object), self)
|
144
134
|
when Date
|
145
135
|
Arel::Nodes.build_quoted(Time.utc(object.year, object.month, object.day, 0, 0, 0), self)
|
146
136
|
else
|
147
|
-
raise(ArgumentError, "#{object.class}
|
137
|
+
raise(ArgumentError, "#{object.class} can not be converted to Datetime")
|
148
138
|
end
|
149
139
|
end
|
150
140
|
|
@@ -162,9 +152,10 @@ module ArelExtensions
|
|
162
152
|
when NilClass
|
163
153
|
0
|
164
154
|
else
|
165
|
-
raise(ArgumentError, "#{object.class}
|
155
|
+
raise(ArgumentError, "#{object.class} can not be converted to NUMBER arg")
|
166
156
|
end
|
167
157
|
end
|
158
|
+
|
168
159
|
end
|
169
160
|
end
|
170
161
|
end
|