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,7 +1,19 @@
|
|
1
1
|
module ArelExtensions
|
2
2
|
module Visitors
|
3
|
-
|
4
|
-
Arel::Visitors.
|
3
|
+
|
4
|
+
Arel::Visitors.send(:remove_const,'Oracle12') if Arel::Visitors.const_defined?('Oracle12')
|
5
|
+
Arel::Visitors.const_set('Oracle12',Class.new(Arel::Visitors::Oracle)).class_eval do
|
6
|
+
def visit_Arel_Nodes_SelectStatement(o, collector)
|
7
|
+
# Oracle does not allow LIMIT clause with select for update
|
8
|
+
if o.limit && o.lock
|
9
|
+
raise ArgumentError, <<-MSG
|
10
|
+
'Combination of limit and lock is not supported.
|
11
|
+
because generated SQL statements
|
12
|
+
`SELECT FOR UPDATE and FETCH FIRST n ROWS` generates ORA-02014.`
|
13
|
+
MSG
|
14
|
+
end
|
15
|
+
super
|
16
|
+
end
|
5
17
|
|
6
18
|
def visit_Arel_Nodes_SelectOptions(o, collector)
|
7
19
|
collector = maybe_visit o.offset, collector
|
@@ -10,21 +22,21 @@ module ArelExtensions
|
|
10
22
|
end
|
11
23
|
|
12
24
|
def visit_Arel_Nodes_Limit(o, collector)
|
13
|
-
collector <<
|
25
|
+
collector << "FETCH FIRST "
|
14
26
|
collector = visit o.expr, collector
|
15
|
-
collector <<
|
27
|
+
collector << " ROWS ONLY"
|
16
28
|
end
|
17
29
|
|
18
30
|
def visit_Arel_Nodes_Offset(o, collector)
|
19
|
-
collector <<
|
31
|
+
collector << "OFFSET "
|
20
32
|
visit o.expr, collector
|
21
|
-
collector <<
|
33
|
+
collector << " ROWS"
|
22
34
|
end
|
23
35
|
|
24
36
|
def visit_Arel_Nodes_Except(o, collector)
|
25
|
-
collector <<
|
26
|
-
collector = infix_value o, collector,
|
27
|
-
collector <<
|
37
|
+
collector << "( "
|
38
|
+
collector = infix_value o, collector, " MINUS "
|
39
|
+
collector << " )"
|
28
40
|
end
|
29
41
|
|
30
42
|
def visit_Arel_Nodes_UpdateStatement(o, collector)
|
@@ -43,25 +55,25 @@ module ArelExtensions
|
|
43
55
|
end
|
44
56
|
|
45
57
|
def is_distinct_from(o, collector)
|
46
|
-
collector <<
|
58
|
+
collector << "DECODE("
|
47
59
|
collector = visit [o.left, o.right, 0, 1], collector
|
48
|
-
collector <<
|
60
|
+
collector << ")"
|
49
61
|
end
|
50
62
|
|
51
|
-
def visit_ArelExtensions_Nodes_Json o,
|
63
|
+
def visit_ArelExtensions_Nodes_Json o,collector
|
52
64
|
case o.dict
|
53
65
|
when Array
|
54
66
|
collector << 'json_array('
|
55
|
-
o.dict.each.with_index do |v,
|
67
|
+
o.dict.each.with_index do |v,i|
|
56
68
|
if i != 0
|
57
69
|
collector << Arel::Visitors::MySQL::COMMA
|
58
70
|
end
|
59
|
-
collector
|
71
|
+
collector = visit v, collector
|
60
72
|
end
|
61
73
|
collector << ')'
|
62
74
|
when Hash
|
63
75
|
collector << 'json__object('
|
64
|
-
o.dict.each.with_index do |(k,
|
76
|
+
o.dict.each.with_index do |(k,v),i|
|
65
77
|
if i != 0
|
66
78
|
collector << Arel::Visitors::MySQL::COMMA
|
67
79
|
end
|
@@ -72,11 +84,11 @@ module ArelExtensions
|
|
72
84
|
collector << 'FORMAT JSON'
|
73
85
|
end
|
74
86
|
collector << ')'
|
75
|
-
when String,
|
76
|
-
collector = visit Arel.
|
87
|
+
when String,Numeric,TrueClass,FalseClass
|
88
|
+
collector = visit Arel::Nodes.build_quoted("#{o.dict}"), collector
|
77
89
|
collector << ' FORMAT JSON'
|
78
90
|
when NilClass
|
79
|
-
collector
|
91
|
+
collector << %Q['null' FORMAT JSON]
|
80
92
|
when Arel::Attributes::Attribute
|
81
93
|
collector = visit o.dict.cast('JSON'), collector
|
82
94
|
else
|
@@ -85,6 +97,7 @@ module ArelExtensions
|
|
85
97
|
end
|
86
98
|
collector
|
87
99
|
end
|
100
|
+
|
88
101
|
end
|
89
102
|
end
|
90
103
|
end
|