arel_extensions 2.1.1 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -2
- data/.github/workflows/ruby.yml +4 -4
- data/.rubocop.yml +25 -1
- data/Gemfile +10 -10
- data/README.md +24 -4
- data/Rakefile +4 -4
- data/TODO +0 -1
- data/arel_extensions.gemspec +11 -11
- data/gemfiles/rails3.gemfile +10 -10
- data/gemfiles/rails4.gemfile +13 -13
- data/gemfiles/rails5_0.gemfile +12 -12
- data/gemfiles/rails5_1_4.gemfile +12 -12
- data/gemfiles/rails5_2.gemfile +13 -13
- data/gemfiles/rails6.gemfile +11 -11
- data/gemfiles/rails6_1.gemfile +11 -11
- data/gemfiles/rails7.gemfile +7 -7
- data/gemspecs/arel_extensions-v1.gemspec +12 -12
- data/gemspecs/arel_extensions-v2.gemspec +11 -11
- data/init/mssql.sql +0 -0
- data/init/mysql.sql +0 -0
- data/init/oracle.sql +0 -0
- data/init/postgresql.sql +0 -0
- data/init/sqlite.sql +0 -0
- data/lib/arel_extensions/attributes.rb +2 -2
- data/lib/arel_extensions/boolean_functions.rb +2 -4
- data/lib/arel_extensions/common_sql_functions.rb +10 -10
- data/lib/arel_extensions/comparators.rb +14 -14
- data/lib/arel_extensions/date_duration.rb +7 -7
- data/lib/arel_extensions/helpers.rb +16 -13
- data/lib/arel_extensions/insert_manager.rb +1 -1
- data/lib/arel_extensions/math.rb +16 -18
- data/lib/arel_extensions/math_functions.rb +18 -18
- data/lib/arel_extensions/nodes/abs.rb +0 -0
- data/lib/arel_extensions/nodes/aggregate_function.rb +0 -0
- data/lib/arel_extensions/nodes/blank.rb +1 -1
- data/lib/arel_extensions/nodes/case.rb +4 -6
- data/lib/arel_extensions/nodes/cast.rb +3 -3
- data/lib/arel_extensions/nodes/ceil.rb +0 -0
- data/lib/arel_extensions/nodes/change_case.rb +0 -0
- data/lib/arel_extensions/nodes/coalesce.rb +0 -0
- data/lib/arel_extensions/nodes/collate.rb +9 -9
- data/lib/arel_extensions/nodes/concat.rb +2 -2
- data/lib/arel_extensions/nodes/date_diff.rb +6 -6
- data/lib/arel_extensions/nodes/duration.rb +0 -0
- data/lib/arel_extensions/nodes/find_in_set.rb +0 -0
- data/lib/arel_extensions/nodes/floor.rb +0 -0
- data/lib/arel_extensions/nodes/format.rb +1 -1
- data/lib/arel_extensions/nodes/formatted_number.rb +2 -2
- data/lib/arel_extensions/nodes/function.rb +21 -21
- data/lib/arel_extensions/nodes/is_null.rb +0 -0
- data/lib/arel_extensions/nodes/json.rb +7 -7
- data/lib/arel_extensions/nodes/length.rb +0 -0
- data/lib/arel_extensions/nodes/levenshtein_distance.rb +1 -1
- data/lib/arel_extensions/nodes/locate.rb +0 -0
- data/lib/arel_extensions/nodes/log10.rb +0 -0
- data/lib/arel_extensions/nodes/matches.rb +1 -1
- data/lib/arel_extensions/nodes/md5.rb +0 -0
- data/lib/arel_extensions/nodes/power.rb +0 -0
- data/lib/arel_extensions/nodes/rand.rb +0 -0
- data/lib/arel_extensions/nodes/repeat.rb +0 -0
- data/lib/arel_extensions/nodes/replace.rb +2 -2
- data/lib/arel_extensions/nodes/round.rb +0 -0
- data/lib/arel_extensions/nodes/soundex.rb +2 -2
- data/lib/arel_extensions/nodes/std.rb +0 -0
- data/lib/arel_extensions/nodes/substring.rb +0 -0
- data/lib/arel_extensions/nodes/sum.rb +0 -0
- data/lib/arel_extensions/nodes/then.rb +0 -0
- data/lib/arel_extensions/nodes/trim.rb +0 -0
- data/lib/arel_extensions/nodes/union.rb +4 -4
- data/lib/arel_extensions/nodes/union_all.rb +3 -3
- data/lib/arel_extensions/nodes/wday.rb +0 -0
- data/lib/arel_extensions/nodes.rb +0 -0
- data/lib/arel_extensions/null_functions.rb +0 -0
- data/lib/arel_extensions/predications.rb +10 -10
- data/lib/arel_extensions/railtie.rb +1 -1
- data/lib/arel_extensions/set_functions.rb +3 -3
- data/lib/arel_extensions/string_functions.rb +8 -8
- data/lib/arel_extensions/tasks.rb +2 -2
- data/lib/arel_extensions/version.rb +1 -1
- data/lib/arel_extensions/visitors/convert_format.rb +0 -0
- data/lib/arel_extensions/visitors/ibm_db.rb +19 -19
- data/lib/arel_extensions/visitors/mssql.rb +139 -118
- data/lib/arel_extensions/visitors/mysql.rb +145 -144
- data/lib/arel_extensions/visitors/oracle.rb +136 -128
- data/lib/arel_extensions/visitors/oracle12.rb +16 -16
- data/lib/arel_extensions/visitors/postgresql.rb +147 -136
- data/lib/arel_extensions/visitors/sqlite.rb +83 -85
- data/lib/arel_extensions/visitors/to_sql.rb +143 -148
- data/lib/arel_extensions/visitors.rb +7 -7
- data/lib/arel_extensions.rb +46 -32
- data/test/arelx_test_helper.rb +14 -14
- data/test/database.yml +5 -5
- data/test/real_db_test.rb +78 -78
- data/test/support/fake_record.rb +1 -1
- data/test/test_comparators.rb +5 -5
- data/test/visitors/test_bulk_insert_oracle.rb +4 -4
- data/test/visitors/test_bulk_insert_sqlite.rb +4 -4
- data/test/visitors/test_bulk_insert_to_sql.rb +4 -4
- data/test/visitors/test_oracle.rb +14 -14
- data/test/visitors/test_to_sql.rb +82 -82
- data/test/with_ar/all_agnostic_test.rb +415 -313
- data/test/with_ar/insert_agnostic_test.rb +17 -14
- data/test/with_ar/test_bulk_sqlite.rb +4 -4
- data/test/with_ar/test_math_sqlite.rb +12 -12
- data/test/with_ar/test_string_mysql.rb +20 -20
- data/test/with_ar/test_string_sqlite.rb +20 -20
- data/version_v1.rb +1 -1
- data/version_v2.rb +1 -1
- metadata +2 -9
- data/.travis/oracle/download.js +0 -152
- data/.travis/oracle/download.sh +0 -30
- data/.travis/oracle/download_ojdbc.js +0 -116
- data/.travis/oracle/install.sh +0 -34
- data/.travis/setup_accounts.sh +0 -9
- data/.travis/sqlite3/extension-functions.sh +0 -6
- data/.travis.yml +0 -193
@@ -1,7 +1,7 @@
|
|
1
1
|
module ArelExtensions
|
2
2
|
module Visitors
|
3
|
-
Arel::Visitors.send(:remove_const,'Oracle12') if Arel::Visitors.const_defined?('Oracle12')
|
4
|
-
Arel::Visitors.const_set('Oracle12',Class.new(Arel::Visitors::Oracle)).class_eval do
|
3
|
+
Arel::Visitors.send(:remove_const, 'Oracle12') if Arel::Visitors.const_defined?('Oracle12')
|
4
|
+
Arel::Visitors.const_set('Oracle12', Class.new(Arel::Visitors::Oracle)).class_eval do
|
5
5
|
|
6
6
|
def visit_Arel_Nodes_SelectOptions(o, collector)
|
7
7
|
collector = maybe_visit o.offset, collector
|
@@ -10,21 +10,21 @@ module ArelExtensions
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def visit_Arel_Nodes_Limit(o, collector)
|
13
|
-
collector <<
|
13
|
+
collector << 'FETCH FIRST '
|
14
14
|
collector = visit o.expr, collector
|
15
|
-
collector <<
|
15
|
+
collector << ' ROWS ONLY'
|
16
16
|
end
|
17
17
|
|
18
18
|
def visit_Arel_Nodes_Offset(o, collector)
|
19
|
-
collector <<
|
19
|
+
collector << 'OFFSET '
|
20
20
|
visit o.expr, collector
|
21
|
-
collector <<
|
21
|
+
collector << ' ROWS'
|
22
22
|
end
|
23
23
|
|
24
24
|
def visit_Arel_Nodes_Except(o, collector)
|
25
|
-
collector <<
|
26
|
-
collector = infix_value o, collector,
|
27
|
-
collector <<
|
25
|
+
collector << '( '
|
26
|
+
collector = infix_value o, collector, ' MINUS '
|
27
|
+
collector << ' )'
|
28
28
|
end
|
29
29
|
|
30
30
|
def visit_Arel_Nodes_UpdateStatement(o, collector)
|
@@ -43,16 +43,16 @@ module ArelExtensions
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def is_distinct_from(o, collector)
|
46
|
-
collector <<
|
46
|
+
collector << 'DECODE('
|
47
47
|
collector = visit [o.left, o.right, 0, 1], collector
|
48
|
-
collector <<
|
48
|
+
collector << ')'
|
49
49
|
end
|
50
50
|
|
51
|
-
def visit_ArelExtensions_Nodes_Json o,collector
|
51
|
+
def visit_ArelExtensions_Nodes_Json o, collector
|
52
52
|
case o.dict
|
53
53
|
when Array
|
54
54
|
collector << 'json_array('
|
55
|
-
o.dict.each.with_index do |v,i|
|
55
|
+
o.dict.each.with_index do |v, i|
|
56
56
|
if i != 0
|
57
57
|
collector << Arel::Visitors::MySQL::COMMA
|
58
58
|
end
|
@@ -61,7 +61,7 @@ module ArelExtensions
|
|
61
61
|
collector << ')'
|
62
62
|
when Hash
|
63
63
|
collector << 'json__object('
|
64
|
-
o.dict.each.with_index do |(k,v),i|
|
64
|
+
o.dict.each.with_index do |(k, v), i|
|
65
65
|
if i != 0
|
66
66
|
collector << Arel::Visitors::MySQL::COMMA
|
67
67
|
end
|
@@ -73,10 +73,10 @@ module ArelExtensions
|
|
73
73
|
end
|
74
74
|
collector << ')'
|
75
75
|
when String, Numeric, TrueClass, FalseClass
|
76
|
-
collector = visit Arel
|
76
|
+
collector = visit Arel.quoted("#{o.dict}"), collector
|
77
77
|
collector << ' FORMAT JSON'
|
78
78
|
when NilClass
|
79
|
-
collector
|
79
|
+
collector << %Q['null' FORMAT JSON]
|
80
80
|
when Arel::Attributes::Attribute
|
81
81
|
collector = visit o.dict.cast('JSON'), collector
|
82
82
|
else
|