arel_extensions 1.2.17 → 1.2.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +102 -0
- data/Gemfile +10 -10
- data/Rakefile +4 -4
- data/arel_extensions.gemspec +1 -1
- 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/gemfiles/rails6.gemfile +13 -13
- data/gemfiles/rails6_1.gemfile +30 -0
- data/gemspecs/arel_extensions-v1.gemspec +28 -0
- data/{gemspec_v2 → gemspecs}/arel_extensions-v2.gemspec +0 -0
- data/generate_gems.sh +4 -3
- data/lib/arel_extensions.rb +23 -5
- data/lib/arel_extensions/attributes.rb +0 -0
- data/lib/arel_extensions/boolean_functions.rb +3 -7
- data/lib/arel_extensions/common_sql_functions.rb +0 -2
- data/lib/arel_extensions/comparators.rb +11 -14
- data/lib/arel_extensions/date_duration.rb +4 -5
- data/lib/arel_extensions/insert_manager.rb +16 -17
- data/lib/arel_extensions/math.rb +8 -9
- data/lib/arel_extensions/math_functions.rb +22 -20
- data/lib/arel_extensions/nodes/abs.rb +0 -1
- data/lib/arel_extensions/nodes/aggregate_function.rb +0 -1
- data/lib/arel_extensions/nodes/blank.rb +0 -1
- data/lib/arel_extensions/nodes/case.rb +3 -4
- data/lib/arel_extensions/nodes/cast.rb +0 -1
- 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 +0 -1
- data/lib/arel_extensions/nodes/collate.rb +0 -1
- data/lib/arel_extensions/nodes/concat.rb +2 -4
- data/lib/arel_extensions/nodes/date_diff.rb +4 -5
- data/lib/arel_extensions/nodes/duration.rb +0 -1
- data/lib/arel_extensions/nodes/find_in_set.rb +0 -1
- data/lib/arel_extensions/nodes/floor.rb +1 -1
- data/lib/arel_extensions/nodes/format.rb +1 -0
- data/lib/arel_extensions/nodes/formatted_number.rb +0 -1
- data/lib/arel_extensions/nodes/function.rb +8 -5
- data/lib/arel_extensions/nodes/is_null.rb +0 -0
- data/lib/arel_extensions/nodes/json.rb +0 -6
- data/lib/arel_extensions/nodes/length.rb +5 -0
- data/lib/arel_extensions/nodes/levenshtein_distance.rb +0 -0
- data/lib/arel_extensions/nodes/locate.rb +0 -1
- data/lib/arel_extensions/nodes/log10.rb +1 -2
- data/lib/arel_extensions/nodes/matches.rb +0 -2
- data/lib/arel_extensions/nodes/md5.rb +0 -1
- data/lib/arel_extensions/nodes/power.rb +0 -1
- data/lib/arel_extensions/nodes/rand.rb +0 -1
- data/lib/arel_extensions/nodes/repeat.rb +0 -2
- data/lib/arel_extensions/nodes/replace.rb +0 -2
- data/lib/arel_extensions/nodes/round.rb +0 -1
- data/lib/arel_extensions/nodes/soundex.rb +0 -1
- data/lib/arel_extensions/nodes/std.rb +4 -5
- data/lib/arel_extensions/nodes/substring.rb +0 -1
- 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 -2
- data/lib/arel_extensions/nodes/union.rb +0 -2
- data/lib/arel_extensions/nodes/union_all.rb +0 -2
- data/lib/arel_extensions/nodes/wday.rb +0 -4
- data/lib/arel_extensions/null_functions.rb +3 -5
- data/lib/arel_extensions/predications.rb +2 -3
- data/lib/arel_extensions/railtie.rb +5 -5
- data/lib/arel_extensions/set_functions.rb +0 -2
- data/lib/arel_extensions/string_functions.rb +30 -23
- data/lib/arel_extensions/tasks.rb +1 -1
- data/lib/arel_extensions/version.rb +1 -1
- data/lib/arel_extensions/visitors.rb +68 -60
- data/lib/arel_extensions/visitors/convert_format.rb +37 -0
- data/lib/arel_extensions/visitors/ibm_db.rb +4 -11
- data/lib/arel_extensions/visitors/mssql.rb +50 -45
- data/lib/arel_extensions/visitors/mysql.rb +63 -65
- data/lib/arel_extensions/visitors/oracle.rb +50 -57
- data/lib/arel_extensions/visitors/oracle12.rb +1 -14
- data/lib/arel_extensions/visitors/postgresql.rb +39 -34
- data/lib/arel_extensions/visitors/sqlite.rb +23 -18
- data/lib/arel_extensions/visitors/to_sql.rb +58 -48
- data/test/arelx_test_helper.rb +0 -2
- data/test/database.yml +2 -0
- data/test/real_db_test.rb +26 -41
- data/test/support/fake_record.rb +1 -1
- data/test/test_comparators.rb +0 -4
- data/test/visitors/test_bulk_insert_oracle.rb +0 -1
- data/test/visitors/test_bulk_insert_sqlite.rb +0 -2
- data/test/visitors/test_oracle.rb +1 -2
- data/test/visitors/test_to_sql.rb +16 -25
- data/test/with_ar/all_agnostic_test.rb +140 -139
- data/test/with_ar/insert_agnostic_test.rb +0 -2
- data/test/with_ar/test_bulk_sqlite.rb +0 -4
- data/test/with_ar/test_math_sqlite.rb +4 -8
- data/test/with_ar/test_string_mysql.rb +1 -5
- data/test/with_ar/test_string_sqlite.rb +1 -5
- data/version_v1.rb +1 -1
- data/version_v2.rb +1 -1
- metadata +8 -4
@@ -3,7 +3,6 @@ require 'date'
|
|
3
3
|
|
4
4
|
module ArelExtensions
|
5
5
|
module WthAr
|
6
|
-
|
7
6
|
class InsertManagerTest < Minitest::Test
|
8
7
|
def setup_db
|
9
8
|
ActiveRecord::Base.configurations = YAML.load_file('test/database.yml')
|
@@ -79,7 +78,6 @@ END;])
|
|
79
78
|
assert_equal 4, User.count, "insertions failed"
|
80
79
|
|
81
80
|
end
|
82
|
-
|
83
81
|
end
|
84
82
|
end
|
85
83
|
end
|
@@ -2,9 +2,7 @@ require 'arelx_test_helper'
|
|
2
2
|
|
3
3
|
module ArelExtensions
|
4
4
|
module WthAr
|
5
|
-
|
6
5
|
describe 'the sqlite visitor' do
|
7
|
-
|
8
6
|
before do
|
9
7
|
ActiveRecord::Base.configurations = YAML.load_file('test/database.yml')
|
10
8
|
ActiveRecord::Base.establish_connection(ENV['DB'] || (RUBY_PLATFORM == 'java' ? :"jdbc-sqlite" : :sqlite))
|
@@ -42,8 +40,6 @@ module ArelExtensions
|
|
42
40
|
.must_be_like %Q[INSERT INTO "users" ("id", "name", "comments", "created_at")
|
43
41
|
SELECT 23 AS 'id', 'nom1' AS 'name', 'sdfdsfdsfsdf' AS 'comments', '2016-01-01' AS 'created_at' UNION ALL SELECT 25, 'nom2', 'sdfdsfdsfsdf', '2016-01-01']
|
44
42
|
end
|
45
|
-
|
46
43
|
end
|
47
|
-
|
48
44
|
end
|
49
45
|
end
|
@@ -2,9 +2,7 @@ require 'arelx_test_helper'
|
|
2
2
|
|
3
3
|
module ArelExtensions
|
4
4
|
module WthAr
|
5
|
-
|
6
5
|
describe 'the sqlite visitor can do maths' do
|
7
|
-
|
8
6
|
before do
|
9
7
|
ActiveRecord::Base.configurations = YAML.load_file('test/database.yml')
|
10
8
|
ActiveRecord::Base.establish_connection(ENV['DB'] || (RUBY_PLATFORM == 'java' ? :"jdbc-sqlite" : :sqlite))
|
@@ -44,21 +42,19 @@ module ArelExtensions
|
|
44
42
|
end
|
45
43
|
|
46
44
|
it "should do maths" do
|
47
|
-
#ABS
|
45
|
+
# ABS
|
48
46
|
assert_equal 20, User.where(:id => @neg.id).select(@age.abs.as("res")).first.res
|
49
47
|
assert_equal 14, User.where(:id => @laure.id).select((@age - 39).abs.as("res")).first.res
|
50
48
|
|
51
|
-
#CEIL # require extensions
|
49
|
+
# CEIL # require extensions
|
52
50
|
|
53
51
|
# RAND
|
54
|
-
# puts User.where(@table[:score].eq(20.16)).order(Arel.rand).limit(50).to_sql if User.where(@table[:score].eq(20.16)).order(Arel.rand).limit(50).count == 0
|
55
|
-
# assert_equal 5, User.where(@table[:score].eq(20.16)).order(Arel.rand).limit(50).count
|
52
|
+
# puts User.where(@table[:score].eq(20.16)).order(Arel.rand).limit(50).to_sql if User.where(@table[:score].eq(20.16)).order(Arel.rand).limit(50).count == 0
|
53
|
+
# assert_equal 5, User.where(@table[:score].eq(20.16)).order(Arel.rand).limit(50).count
|
56
54
|
assert 42 != User.select(Arel.rand.as('res')).first.res
|
57
55
|
assert 0 <= User.select(Arel.rand.abs.as('res')).first.res
|
58
56
|
assert_equal 8, User.order(Arel.rand).limit(50).count
|
59
57
|
end
|
60
|
-
|
61
58
|
end
|
62
|
-
|
63
59
|
end
|
64
60
|
end
|
@@ -3,9 +3,7 @@ require 'date'
|
|
3
3
|
|
4
4
|
module ArelExtensions
|
5
5
|
module WthAr
|
6
|
-
|
7
6
|
describe 'the mysql visitor can do string operations' do
|
8
|
-
|
9
7
|
before do
|
10
8
|
ActiveRecord::Base.configurations = YAML.load_file('test/database.yml')
|
11
9
|
ActiveRecord::Base.establish_connection(ENV['DB'] || (RUBY_PLATFORM == 'java' ? :"jdbc-mysql" : :mysql))
|
@@ -59,7 +57,7 @@ module ArelExtensions
|
|
59
57
|
assert_equal "Sophie15", @sophie.select((User.arel_table[:name] + User.arel_table[:age]).as("res")).first.res
|
60
58
|
assert_equal "SophieSophie", @sophie.select((User.arel_table[:name] + User.arel_table[:name]).as("res")).first.res
|
61
59
|
assert_equal "Sophie2016-05-23", @sophie.select((User.arel_table[:name] + User.arel_table[:created_at]).as("res")).first.res
|
62
|
-
#concat Integer
|
60
|
+
# concat Integer
|
63
61
|
assert_equal 1, User.where((User.arel_table[:age] + 10).eq(33)).count
|
64
62
|
assert_equal 1, User.where((User.arel_table[:age] + "1").eq(6)).count
|
65
63
|
assert_equal 1, User.where((User.arel_table[:age] + User.arel_table[:age]).eq(10)).count
|
@@ -68,8 +66,6 @@ module ArelExtensions
|
|
68
66
|
assert_equal "LucaX", User.where(:id => @lucas).select(@name.replace("s","X").as("res")).first.res
|
69
67
|
assert_equal "replace", User.where(:id => @lucas).select(@name.replace(@name,"replace").as("res")).first.res
|
70
68
|
end
|
71
|
-
|
72
69
|
end
|
73
|
-
|
74
70
|
end
|
75
71
|
end
|
@@ -3,9 +3,7 @@ require 'date'
|
|
3
3
|
|
4
4
|
module ArelExtensions
|
5
5
|
module WthAr
|
6
|
-
|
7
6
|
describe 'the sqlite visitor can do string operations' do
|
8
|
-
|
9
7
|
before do
|
10
8
|
ActiveRecord::Base.configurations = YAML.load_file('test/database.yml')
|
11
9
|
ActiveRecord::Base.establish_connection(ENV['DB'] || (RUBY_PLATFORM == 'java' ? :"jdbc-sqlite" : :sqlite))
|
@@ -52,7 +50,7 @@ module ArelExtensions
|
|
52
50
|
assert_equal "Sophie15", @sophie.select((User.arel_table[:name] + User.arel_table[:age]).as("res")).first.res
|
53
51
|
assert_equal "SophieSophie", @sophie.select((User.arel_table[:name] + User.arel_table[:name]).as("res")).first.res
|
54
52
|
assert_equal "Sophie2016-05-23", @sophie.select((User.arel_table[:name] + User.arel_table[:created_at]).as("res")).first.res
|
55
|
-
#concat Integer
|
53
|
+
# concat Integer
|
56
54
|
assert_equal 1, User.where((User.arel_table[:age] + 10).eq(33)).count
|
57
55
|
assert_equal 1, User.where((User.arel_table[:age] + "1").eq(6)).count
|
58
56
|
assert_equal 1, User.where((User.arel_table[:age] + User.arel_table[:age]).eq(10)).count
|
@@ -61,8 +59,6 @@ module ArelExtensions
|
|
61
59
|
assert_equal "LucaX", User.where(:id => @lucas).select(@name.replace("s","X").as("res")).first.res
|
62
60
|
assert_equal "replace", User.where(:id => @lucas).select(@name.replace(@name,"replace").as("res")).first.res
|
63
61
|
end
|
64
|
-
|
65
62
|
end
|
66
|
-
|
67
63
|
end
|
68
64
|
end
|
data/version_v1.rb
CHANGED
data/version_v2.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arel_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yann Azoury
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-04-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: arel
|
@@ -81,6 +81,7 @@ extra_rdoc_files:
|
|
81
81
|
- functions.html
|
82
82
|
files:
|
83
83
|
- ".codeclimate.yml"
|
84
|
+
- ".github/workflows/ruby.yml"
|
84
85
|
- ".gitignore"
|
85
86
|
- ".rubocop.yml"
|
86
87
|
- ".travis.yml"
|
@@ -105,7 +106,9 @@ files:
|
|
105
106
|
- gemfiles/rails5_1_4.gemfile
|
106
107
|
- gemfiles/rails5_2.gemfile
|
107
108
|
- gemfiles/rails6.gemfile
|
108
|
-
-
|
109
|
+
- gemfiles/rails6_1.gemfile
|
110
|
+
- gemspecs/arel_extensions-v1.gemspec
|
111
|
+
- gemspecs/arel_extensions-v2.gemspec
|
109
112
|
- generate_gems.sh
|
110
113
|
- init/mssql.sql
|
111
114
|
- init/mysql.sql
|
@@ -169,6 +172,7 @@ files:
|
|
169
172
|
- lib/arel_extensions/tasks.rb
|
170
173
|
- lib/arel_extensions/version.rb
|
171
174
|
- lib/arel_extensions/visitors.rb
|
175
|
+
- lib/arel_extensions/visitors/convert_format.rb
|
172
176
|
- lib/arel_extensions/visitors/ibm_db.rb
|
173
177
|
- lib/arel_extensions/visitors/mssql.rb
|
174
178
|
- lib/arel_extensions/visitors/mysql.rb
|
@@ -218,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
222
|
- !ruby/object:Gem::Version
|
219
223
|
version: '0'
|
220
224
|
requirements: []
|
221
|
-
rubygems_version: 3.
|
225
|
+
rubygems_version: 3.1.2
|
222
226
|
signing_key:
|
223
227
|
specification_version: 4
|
224
228
|
summary: Extending Arel
|