arel_extensions 1.2.15 → 1.2.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +102 -0
  3. data/.travis.yml +2 -0
  4. data/Gemfile +10 -10
  5. data/Rakefile +4 -4
  6. data/arel_extensions.gemspec +1 -1
  7. data/gemfiles/rails3.gemfile +9 -9
  8. data/gemfiles/rails4.gemfile +13 -13
  9. data/gemfiles/rails5_0.gemfile +13 -13
  10. data/gemfiles/rails5_1_4.gemfile +13 -13
  11. data/gemfiles/rails5_2.gemfile +13 -13
  12. data/gemfiles/rails6.gemfile +13 -13
  13. data/gemfiles/rails6_1.gemfile +30 -0
  14. data/gemspecs/arel_extensions-v1.gemspec +28 -0
  15. data/{gemspec_v2 → gemspecs}/arel_extensions-v2.gemspec +0 -0
  16. data/generate_gems.sh +4 -3
  17. data/lib/arel_extensions.rb +11 -5
  18. data/lib/arel_extensions/attributes.rb +0 -0
  19. data/lib/arel_extensions/boolean_functions.rb +21 -5
  20. data/lib/arel_extensions/common_sql_functions.rb +2 -4
  21. data/lib/arel_extensions/comparators.rb +11 -14
  22. data/lib/arel_extensions/date_duration.rb +4 -5
  23. data/lib/arel_extensions/insert_manager.rb +16 -17
  24. data/lib/arel_extensions/math.rb +8 -9
  25. data/lib/arel_extensions/math_functions.rb +22 -20
  26. data/lib/arel_extensions/nodes/abs.rb +0 -1
  27. data/lib/arel_extensions/nodes/aggregate_function.rb +0 -1
  28. data/lib/arel_extensions/nodes/blank.rb +0 -1
  29. data/lib/arel_extensions/nodes/case.rb +3 -4
  30. data/lib/arel_extensions/nodes/cast.rb +4 -2
  31. data/lib/arel_extensions/nodes/ceil.rb +1 -1
  32. data/lib/arel_extensions/nodes/change_case.rb +0 -0
  33. data/lib/arel_extensions/nodes/coalesce.rb +0 -1
  34. data/lib/arel_extensions/nodes/collate.rb +0 -1
  35. data/lib/arel_extensions/nodes/concat.rb +2 -4
  36. data/lib/arel_extensions/nodes/date_diff.rb +7 -8
  37. data/lib/arel_extensions/nodes/duration.rb +0 -1
  38. data/lib/arel_extensions/nodes/find_in_set.rb +0 -1
  39. data/lib/arel_extensions/nodes/floor.rb +1 -1
  40. data/lib/arel_extensions/nodes/format.rb +27 -1
  41. data/lib/arel_extensions/nodes/formatted_number.rb +0 -1
  42. data/lib/arel_extensions/nodes/function.rb +24 -17
  43. data/lib/arel_extensions/nodes/is_null.rb +0 -0
  44. data/lib/arel_extensions/nodes/json.rb +11 -17
  45. data/lib/arel_extensions/nodes/length.rb +0 -1
  46. data/lib/arel_extensions/nodes/levenshtein_distance.rb +0 -0
  47. data/lib/arel_extensions/nodes/locate.rb +0 -1
  48. data/lib/arel_extensions/nodes/log10.rb +1 -2
  49. data/lib/arel_extensions/nodes/matches.rb +0 -2
  50. data/lib/arel_extensions/nodes/md5.rb +0 -1
  51. data/lib/arel_extensions/nodes/power.rb +0 -1
  52. data/lib/arel_extensions/nodes/rand.rb +0 -1
  53. data/lib/arel_extensions/nodes/repeat.rb +0 -2
  54. data/lib/arel_extensions/nodes/replace.rb +0 -2
  55. data/lib/arel_extensions/nodes/round.rb +0 -1
  56. data/lib/arel_extensions/nodes/soundex.rb +0 -1
  57. data/lib/arel_extensions/nodes/std.rb +4 -5
  58. data/lib/arel_extensions/nodes/substring.rb +0 -1
  59. data/lib/arel_extensions/nodes/sum.rb +0 -0
  60. data/lib/arel_extensions/nodes/then.rb +0 -0
  61. data/lib/arel_extensions/nodes/trim.rb +0 -2
  62. data/lib/arel_extensions/nodes/union.rb +0 -2
  63. data/lib/arel_extensions/nodes/union_all.rb +0 -2
  64. data/lib/arel_extensions/nodes/wday.rb +0 -4
  65. data/lib/arel_extensions/null_functions.rb +3 -5
  66. data/lib/arel_extensions/predications.rb +5 -6
  67. data/lib/arel_extensions/railtie.rb +5 -5
  68. data/lib/arel_extensions/set_functions.rb +0 -2
  69. data/lib/arel_extensions/string_functions.rb +21 -22
  70. data/lib/arel_extensions/tasks.rb +1 -1
  71. data/lib/arel_extensions/version.rb +1 -1
  72. data/lib/arel_extensions/visitors.rb +68 -60
  73. data/lib/arel_extensions/visitors/convert_format.rb +37 -0
  74. data/lib/arel_extensions/visitors/ibm_db.rb +4 -11
  75. data/lib/arel_extensions/visitors/mssql.rb +49 -44
  76. data/lib/arel_extensions/visitors/mysql.rb +65 -67
  77. data/lib/arel_extensions/visitors/oracle.rb +58 -55
  78. data/lib/arel_extensions/visitors/oracle12.rb +1 -14
  79. data/lib/arel_extensions/visitors/postgresql.rb +41 -34
  80. data/lib/arel_extensions/visitors/sqlite.rb +23 -18
  81. data/lib/arel_extensions/visitors/to_sql.rb +59 -47
  82. data/test/arelx_test_helper.rb +0 -2
  83. data/test/database.yml +2 -0
  84. data/test/real_db_test.rb +27 -42
  85. data/test/support/fake_record.rb +1 -1
  86. data/test/test_comparators.rb +0 -4
  87. data/test/visitors/test_bulk_insert_oracle.rb +0 -1
  88. data/test/visitors/test_bulk_insert_sqlite.rb +0 -2
  89. data/test/visitors/test_oracle.rb +1 -2
  90. data/test/visitors/test_to_sql.rb +16 -25
  91. data/test/with_ar/all_agnostic_test.rb +141 -139
  92. data/test/with_ar/insert_agnostic_test.rb +0 -2
  93. data/test/with_ar/test_bulk_sqlite.rb +0 -4
  94. data/test/with_ar/test_math_sqlite.rb +4 -8
  95. data/test/with_ar/test_string_mysql.rb +1 -5
  96. data/test/with_ar/test_string_sqlite.rb +1 -5
  97. data/version_v1.rb +1 -1
  98. data/version_v2.rb +1 -1
  99. 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
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "1.2.15".freeze
2
+ VERSION = "1.2.23".freeze
3
3
  end
data/version_v2.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "2.0.11".freeze
2
+ VERSION = "2.0.20".freeze
3
3
  end
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.15
4
+ version: 1.2.23
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: 2020-09-17 00:00:00.000000000 Z
13
+ date: 2021-02-04 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
- - gemspec_v2/arel_extensions-v2.gemspec
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.0.2
225
+ rubygems_version: 3.1.2
222
226
  signing_key:
223
227
  specification_version: 4
224
228
  summary: Extending Arel