arel_extensions 1.2.5 → 1.2.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +7 -4
  3. data/.travis.yml +54 -86
  4. data/README.md +7 -2
  5. data/Rakefile +38 -27
  6. data/arel_extensions.gemspec +1 -1
  7. data/functions.html +2 -2
  8. data/gemfiles/rails4.gemfile +1 -1
  9. data/gemfiles/rails6.gemfile +30 -0
  10. data/gemspec_v2/arel_extensions-v2.gemspec +28 -0
  11. data/generate_gems.sh +14 -0
  12. data/lib/arel_extensions.rb +49 -21
  13. data/lib/arel_extensions/attributes.rb +0 -1
  14. data/lib/arel_extensions/boolean_functions.rb +38 -13
  15. data/lib/arel_extensions/common_sql_functions.rb +5 -4
  16. data/lib/arel_extensions/insert_manager.rb +26 -24
  17. data/lib/arel_extensions/math.rb +3 -3
  18. data/lib/arel_extensions/math_functions.rb +4 -4
  19. data/lib/arel_extensions/nodes/abs.rb +0 -0
  20. data/lib/arel_extensions/nodes/case.rb +8 -4
  21. data/lib/arel_extensions/nodes/ceil.rb +0 -0
  22. data/lib/arel_extensions/nodes/coalesce.rb +0 -0
  23. data/lib/arel_extensions/nodes/collate.rb +1 -1
  24. data/lib/arel_extensions/nodes/concat.rb +0 -0
  25. data/lib/arel_extensions/nodes/date_diff.rb +1 -3
  26. data/lib/arel_extensions/nodes/duration.rb +0 -2
  27. data/lib/arel_extensions/nodes/find_in_set.rb +0 -0
  28. data/lib/arel_extensions/nodes/floor.rb +0 -0
  29. data/lib/arel_extensions/nodes/formatted_number.rb +20 -20
  30. data/lib/arel_extensions/nodes/function.rb +0 -0
  31. data/lib/arel_extensions/nodes/is_null.rb +0 -0
  32. data/lib/arel_extensions/nodes/json.rb +43 -30
  33. data/lib/arel_extensions/nodes/length.rb +0 -0
  34. data/lib/arel_extensions/nodes/locate.rb +0 -0
  35. data/lib/arel_extensions/nodes/power.rb +5 -4
  36. data/lib/arel_extensions/nodes/rand.rb +0 -0
  37. data/lib/arel_extensions/nodes/replace.rb +23 -5
  38. data/lib/arel_extensions/nodes/round.rb +5 -5
  39. data/lib/arel_extensions/nodes/soundex.rb +14 -13
  40. data/lib/arel_extensions/nodes/substring.rb +8 -15
  41. data/lib/arel_extensions/nodes/trim.rb +1 -1
  42. data/lib/arel_extensions/nodes/union.rb +0 -1
  43. data/lib/arel_extensions/nodes/union_all.rb +0 -1
  44. data/lib/arel_extensions/nodes/wday.rb +0 -0
  45. data/lib/arel_extensions/predications.rb +35 -33
  46. data/lib/arel_extensions/set_functions.rb +2 -2
  47. data/lib/arel_extensions/string_functions.rb +25 -6
  48. data/lib/arel_extensions/tasks.rb +5 -5
  49. data/lib/arel_extensions/version.rb +1 -1
  50. data/lib/arel_extensions/visitors.rb +1 -1
  51. data/lib/arel_extensions/visitors/ibm_db.rb +1 -1
  52. data/lib/arel_extensions/visitors/mssql.rb +13 -12
  53. data/lib/arel_extensions/visitors/mysql.rb +67 -37
  54. data/lib/arel_extensions/visitors/oracle.rb +14 -14
  55. data/lib/arel_extensions/visitors/oracle12.rb +1 -1
  56. data/lib/arel_extensions/visitors/postgresql.rb +46 -28
  57. data/lib/arel_extensions/visitors/sqlite.rb +52 -44
  58. data/lib/arel_extensions/visitors/to_sql.rb +73 -59
  59. data/test/arelx_test_helper.rb +28 -0
  60. data/test/support/fake_record.rb +4 -0
  61. data/test/test_comparators.rb +8 -7
  62. data/test/visitors/test_bulk_insert_oracle.rb +8 -7
  63. data/test/visitors/test_bulk_insert_sqlite.rb +8 -7
  64. data/test/visitors/test_bulk_insert_to_sql.rb +3 -3
  65. data/test/visitors/test_oracle.rb +41 -41
  66. data/test/visitors/test_to_sql.rb +367 -199
  67. data/test/with_ar/all_agnostic_test.rb +63 -41
  68. data/test/with_ar/insert_agnostic_test.rb +1 -1
  69. data/test/with_ar/test_bulk_sqlite.rb +5 -4
  70. data/test/with_ar/test_math_sqlite.rb +2 -2
  71. data/test/with_ar/test_string_mysql.rb +2 -4
  72. data/test/with_ar/test_string_sqlite.rb +2 -6
  73. data/version_v1.rb +3 -0
  74. data/version_v2.rb +3 -0
  75. metadata +10 -5
  76. data/test/helper.rb +0 -18
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'arelx_test_helper'
2
2
  require 'date'
3
3
 
4
4
  module ArelExtensions
@@ -68,7 +68,8 @@ module ArelExtensions
68
68
  @test = User.where(:id => u.id)
69
69
  u = User.create :age => -42, :name => "Negatif", :comments => '1,22,3,42,2', :created_at => d, :updated_at => d.to_time, :score => 0.17
70
70
  @neg = User.where(:id => u.id)
71
-
71
+ u = User.create :age => 15, :name => "Justin", :created_at => d, :score => 11.0
72
+ @justin = User.where(:id => u.id)
72
73
 
73
74
  @age = User.arel_table[:age]
74
75
  @name = User.arel_table[:name]
@@ -121,6 +122,7 @@ module ArelExtensions
121
122
  assert_equal(-20, t(@camille, @score.ceil)) # -20.16
122
123
  assert_equal(-20, t(@camille, (@score - 0.5).ceil)) # -20.16
123
124
  assert_equal 63, t(@arthur, @age.ceil + 42)
125
+ assert_equal 11, t(@justin, @score.ceil) # 11.0
124
126
  end
125
127
 
126
128
  def test_floor
@@ -129,12 +131,14 @@ module ArelExtensions
129
131
  assert_equal 1, t(@test, @score.floor) # 1.62
130
132
  assert_equal(-9, t(@test, (@score - 10).floor)) # 1.62
131
133
  assert_equal 42, t(@arthur, @score.floor - 23)
134
+ assert_equal 11, t(@justin, @score.floor) # 11.0
135
+ assert_equal(-21, t(@camille, @score.floor)) # # -20.16
132
136
  end
133
137
 
134
138
  def test_rand
135
139
  assert 42 != User.select(Arel.rand.as('res')).first.res
136
140
  assert 0 <= User.select(Arel.rand.abs.as('res')).first.res
137
- assert_equal 8, User.order(Arel.rand).limit(50).count
141
+ assert_equal 9, User.order(Arel.rand).limit(50).count
138
142
  end
139
143
 
140
144
  def test_round
@@ -147,15 +151,15 @@ module ArelExtensions
147
151
  def test_sum
148
152
  if @env_db == 'mssql'
149
153
  skip "SQL Server forces order?" # TODO
150
- assert_equal 68, User.select((@age.sum + 1).as("res"), User.arel_table[:id].sum).take(50).reorder(@age).first.res
151
- assert_equal 134, User.reorder(nil).select((@age.sum + @age.sum).as("res"), User.arel_table[:id].sum).take(50).first.res
152
- assert_equal 201, User.reorder(nil).select(((@age * 3).sum).as("res"), User.arel_table[:id].sum).take(50).first.res
153
- assert_equal 4009, User.reorder(nil).select(((@age * @age).sum).as("res"), User.arel_table[:id].sum).take(50).first.res
154
+ assert_equal 83, User.select((@age.sum + 1).as("res"), User.arel_table[:id].sum).take(50).reorder(@age).first.res
155
+ assert_equal 164, User.reorder(nil).select((@age.sum + @age.sum).as("res"), User.arel_table[:id].sum).take(50).first.res
156
+ assert_equal 246, User.reorder(nil).select(((@age * 3).sum).as("res"), User.arel_table[:id].sum).take(50).first.res
157
+ assert_equal 4234, User.reorder(nil).select(((@age * @age).sum).as("res"), User.arel_table[:id].sum).take(50).first.res
154
158
  else
155
- assert_equal 68, User.select((@age.sum + 1).as("res")).take(50).first.res
156
- assert_equal 134, User.select((@age.sum + @age.sum).as("res")).take(50).first.res
157
- assert_equal 201, User.select((@age * 3).sum.as("res")).take(50).first.res
158
- assert_equal 4009, User.select(((@age * @age).sum).as("res")).take(50).first.res
159
+ assert_equal 83, User.select((@age.sum + 1).as("res")).take(50).first.res
160
+ assert_equal 164, User.select((@age.sum + @age.sum).as("res")).take(50).first.res
161
+ assert_equal 246, User.select((@age * 3).sum.as("res")).take(50).first.res
162
+ assert_equal 4234, User.select(((@age * @age).sum).as("res")).take(50).first.res
159
163
  end
160
164
  end
161
165
 
@@ -268,21 +272,28 @@ module ArelExtensions
268
272
  skip "Sqlite version can't load extension for regexp" if $sqlite && $load_extension_disabled
269
273
  skip "SQL Server does not know about REGEXP without extensions" if @env_db == 'mssql'
270
274
  assert_equal 1, User.where(@name =~ '^M').count
271
- assert_equal 6, User.where(@name !~ '^L').count
275
+ assert_equal 7, User.where(@name !~ '^L').count
272
276
  assert_equal 1, User.where(@name =~ /^M/).count
273
- assert_equal 6, User.where(@name !~ /^L/).count
277
+ assert_equal 7, User.where(@name !~ /^L/).count
274
278
  end
275
279
 
276
280
  def test_imatches
277
281
  #puts User.where(@name.imatches('m%')).to_sql
278
282
  assert_equal 1, User.where(@name.imatches('m%')).count
279
283
  assert_equal 4, User.where(@name.imatches_any(['L%', '%e'])).count
280
- assert_equal 6, User.where(@name.idoes_not_match('L%')).count
284
+ assert_equal 7, User.where(@name.idoes_not_match('L%')).count
281
285
  end
282
286
 
283
287
  def test_replace
284
288
  assert_equal "LucaX", t(@lucas, @name.replace("s", "X"))
285
289
  assert_equal "replace", t(@lucas, @name.replace(@name, "replace"))
290
+
291
+ skip "Sqlite does not seem to support regexp_replace" if $sqlite
292
+ skip "SQL Server does not know about REGEXP without extensions" if @env_db == 'mssql'
293
+ skip "Travis mysql version does not support REGEXP_REPLACE" if @env_db == 'mysql'
294
+ assert_equal "LXcXs", t(@lucas, @name.replace(/[ua]/, "X"))
295
+ assert_equal "LXcXs", t(@lucas, @name.regexp_replace(/[ua]/, "X"))
296
+ assert_equal "LXcXs", t(@lucas, @name.regexp_replace('[ua]', "X"))
286
297
  end
287
298
 
288
299
  def test_replace_once
@@ -295,8 +306,8 @@ module ArelExtensions
295
306
  skip "Sqlite version can't load extension for soundex" if $sqlite && $load_extension_disabled
296
307
  skip "PostgreSql version can't load extension for soundex" if @env_db == 'postgresql'
297
308
  assert_equal "C540", t(@camille, @name.soundex)
298
- assert_equal 8, User.where(@name.soundex.eq(@name.soundex)).count
299
- assert_equal 8, User.where(@name.soundex == @name.soundex).count
309
+ assert_equal 9, User.where(@name.soundex.eq(@name.soundex)).count
310
+ assert_equal 9 , User.where(@name.soundex == @name.soundex).count
300
311
  end
301
312
 
302
313
  def test_change_case
@@ -375,13 +386,13 @@ module ArelExtensions
375
386
  assert_equal 2, User.where(@age <= 10).count
376
387
  assert_equal 3, User.where(@age > 20).count
377
388
  assert_equal 4, User.where(@age >= 20).count
378
- assert_equal 1, User.where(@age > 5).where(@age < 20).count
389
+ assert_equal 2, User.where(@age > 5).where(@age < 20).count
379
390
  end
380
391
 
381
392
  def test_date_comparator
382
393
  d = Date.new(2016, 5, 23)
383
394
  assert_equal 0, User.where(@created_at < d).count
384
- assert_equal 8, User.where(@created_at >= d).count
395
+ assert_equal 9, User.where(@created_at >= d).count
385
396
  end
386
397
 
387
398
  def test_date_duration
@@ -390,10 +401,10 @@ module ArelExtensions
390
401
  assert_equal 0, User.where(@created_at.year.eq("2012")).count
391
402
  #Month
392
403
  assert_equal 5, t(@camille, @created_at.month).to_i
393
- assert_equal 8, User.where(@created_at.month.eq("05")).count
404
+ assert_equal 9, User.where(@created_at.month.eq("05")).count
394
405
  #Week
395
406
  assert_equal(@env_db == 'mssql' ? 22 : 21, t(@arthur, @created_at.week).to_i)
396
- assert_equal 8, User.where(@created_at.month.eq("05")).count
407
+ assert_equal 9, User.where(@created_at.month.eq("05")).count
397
408
  #Day
398
409
  assert_equal 23, t(@laure, @created_at.day).to_i
399
410
  assert_equal 0, User.where(@created_at.day.eq("05")).count
@@ -425,6 +436,7 @@ module ArelExtensions
425
436
  end
426
437
  end
427
438
 
439
+
428
440
  skip "not yet implemented" if $sqlite
429
441
 
430
442
  date1 = Date.new(2016, 5, 23)
@@ -468,15 +480,17 @@ module ArelExtensions
468
480
  # TODO; cast types
469
481
  def test_cast_types
470
482
  assert_equal "5", t(@lucas, @age.cast(:string))
483
+ skip "jdbc adapters does not work properly here (v52 works fine)" if RUBY_PLATFORM =~ /java/i
471
484
  if @env_db == 'mysql' || @env_db == 'postgresql' || @env_db == 'oracle' || @env_db == 'mssql'
472
- assert_equal 1, t(@laure,ArelExtensions::Nodes::Case.new.when(@duration.cast(:time).cast(:string).eq("12:42:21")).then(1).else(0)) unless @env_db == 'oracle' || @env_db == 'mssql'
473
- assert_equal 1, t(@laure,ArelExtensions::Nodes::Case.new.when(@duration.cast(:time).eq("12:42:21")).then(1).else(0)) unless @env_db == 'oracle'
485
+ assert_equal 1, t(@laure,Arel.when(@duration.cast(:time).cast(:string).eq("12:42:21")).then(1).else(0)) unless @env_db == 'oracle' || @env_db == 'mssql'
486
+ assert_equal 1, t(@laure,Arel.when(@duration.cast(:time).eq("12:42:21")).then(1).else(0)) unless @env_db == 'oracle'
474
487
  assert_equal "20.16", t(@laure,@score.cast(:string)).gsub(/[0]*\z/,'')
475
488
  assert_equal "20.161", t(@laure,@score.cast(:string)+1).gsub(/[0]*1\z/,'1')
476
489
  assert_equal 21.16, t(@laure,@score.cast(:string).cast(:decimal)+1)
477
490
  assert_equal 21, t(@laure,@score.cast(:string).cast(:int)+1)
478
491
 
479
492
  assert_equal String, t(@lucas,@updated_at.cast(:string)).class
493
+
480
494
  assert_equal Date, t(@lucas,@updated_at.cast(:date)).class unless @env_db == 'oracle' # DateTime
481
495
  assert_equal Time, t(@lucas,@updated_at.cast(:string).cast(:datetime)).class
482
496
  assert_equal Time, t(@lucas,@updated_at.cast(:time)).class
@@ -526,7 +540,7 @@ module ArelExtensions
526
540
  def test_math_minus
527
541
  d = Date.new(2016, 5, 20)
528
542
  #Datediff
529
- assert_equal 8, User.where((@created_at - @created_at).eq(0)).count
543
+ assert_equal 9, User.where((@created_at - @created_at).eq(0)).count
530
544
  assert_equal 3, @laure.select((@created_at - d).as("res")).first.res.abs.to_i
531
545
  #Substraction
532
546
  assert_equal 0, User.where((@age - 10).eq(50)).count
@@ -567,6 +581,7 @@ module ArelExtensions
567
581
  # Case clause
568
582
  def test_case
569
583
  assert_equal 4, User.find_by_sql(@ut.project(@score.when(20.16).then(1).else(0).as('score_bin')).to_sql).sum(&:score_bin)
584
+ assert_equal 4, User.where(@score.when(20.16).then(1).else(0).eq(1)).count
570
585
  assert_equal 2, t(@arthur, @score.when(65.62,1).else(0)+1)
571
586
  assert_equal 0, t(@arthur, @score.when(65.62,1).else(0)-1)
572
587
  assert_equal "11", t(@arthur, @score.when(65.62).then("1").else("0")+"1")
@@ -644,8 +659,8 @@ module ArelExtensions
644
659
  end
645
660
 
646
661
  def test_subquery_with_order
647
- assert_equal 8, User.where(:name => User.select(:name).order(:name)).count
648
- assert_equal 8, User.where(@ut[:name].in(@ut.project(@ut[:name]).order(@ut[:name]))).count
662
+ assert_equal 9, User.where(:name => User.select(:name).order(:name)).count
663
+ assert_equal 9, User.where(@ut[:name].in(@ut.project(@ut[:name]).order(@ut[:name]))).count
649
664
  if !['mysql'].include?(@env_db) # MySql can't have limit in IN subquery
650
665
  assert_equal 2, User.where(:name => User.select(:name).order(:name).limit(2)).count
651
666
  #assert_equal 6, User.where(:name => User.select(:name).order(:name).offset(2)).count
@@ -713,6 +728,13 @@ module ArelExtensions
713
728
  #assert_equal true , @test.where(@age.not_in([nil,1,2])).blank?
714
729
  end
715
730
 
731
+ def test_in_on_grouping
732
+ skip "We should modify the visitor of IN to make it work" if $sqlite || @env_db == 'mssql'
733
+ assert_equal 2 , User.where(Arel.tuple(@name,@age).in(Arel.tuple('Myung',23),Arel.tuple('Arthur',21))).count
734
+ assert_equal 1 , User.where(Arel.tuple(@name,@age).in(Arel.tuple('Myung',23))).count
735
+ assert_equal 0 , User.where(Arel.tuple(@name,@age).in([])).count
736
+ end
737
+
716
738
  def test_alias_shortened
717
739
  if ['postgresql','oracle'].include?(@env_db)
718
740
  new_alias = Arel.shorten('azerty' * 15)
@@ -727,21 +749,21 @@ module ArelExtensions
727
749
  def test_stat_functions
728
750
  skip "SQLite doesn't work for most on this functions" if $sqlite
729
751
  #puts t(User.where(nil), @score.average)
730
- #puts t(User.where(nil), @score.variance(true))
731
- #puts t(User.where(nil), @score.variance(false))
732
- #puts t(User.where(nil), @score.std(true))
733
- #puts t(User.where(nil), @score.std(false))
734
-
735
- assert ( 15.98625 - t(User.where(nil), @score.average)).abs < 0.01
736
- assert (613.75488 - t(User.where(nil), @score.variance)).abs < 0.01
737
- assert ( 537.0355 - t(User.where(nil), @score.variance(unbiased: false))).abs < 0.01
738
- assert ( 24.77408 - t(User.where(nil), @score.std)).abs < 0.01
739
- assert ( 23.17403 - t(User.where(nil), @score.std(unbiased: false))).abs < 0.01
740
- skip "Not Yet Implemented" if !['postgresql'].include?(@env_db)
741
- assert_equal 2, User.select(@score.std(group: Arel.when(@name > "M").then(0).else(1)).as('res')).map(&:res).uniq.length
742
- assert_equal 2, User.select(@score.variance(group: Arel.when(@name > "M").then(0).else(1)).as('res')).map(&:res).uniq.length
743
- assert_equal 2, User.select(@score.sum(group: Arel.when(@name > "M").then(0).else(1)).as('res')).map(&:res).uniq.length
744
- assert_equal 2, User.select(@comments.group_concat(group: Arel.when(@name > "M").then(0).else(1)).as('res')).map(&:res).uniq.length
752
+ #puts t(User.where(nil), @score.variance(unbiased: true))
753
+ #puts t(User.where(nil), @score.variance(unbiased: false))
754
+ #puts t(User.where(nil), @score.std(unbiased: true))
755
+ #puts t(User.where(nil), @score.std(unbiased: false))
756
+
757
+ assert ( 15.43222 - t(User.where(nil), @score.average)).abs < 0.01
758
+ assert (539.79804 - t(User.where(nil), @score.variance)).abs < 0.01
759
+ assert (479.82048 - t(User.where(nil), @score.variance(unbiased: false))).abs < 0.01
760
+ assert ( 23.23355 - t(User.where(nil), @score.std)).abs < 0.01
761
+ assert ( 21.90480 - t(User.where(nil), @score.std(unbiased: false))).abs < 0.01
762
+ skip "Not Yet Implemented" #if !['postgresql'].include?(@env_db)
763
+ assert_equal 2, User.select(@score.std(group: Arel.when(@name > "M").then(0).else(1)).as('res')).map{|e| e['res']}.uniq.length
764
+ assert_equal 2, User.select(@score.variance(group: Arel.when(@name > "M").then(0).else(1)).as('res')).map{|e|e['res']}.uniq.length
765
+ assert_equal 2, User.select(@score.sum(group: Arel.when(@name > "M").then(0).else(1)).as('res')).map{|e|e['res']}.uniq.length
766
+ assert_equal 2, User.select(@comments.group_concat(group: Arel.when(@name > "M").then(0).else(1)).as('res')).map{|e|e['res']}.uniq.length
745
767
  end
746
768
 
747
769
  def test_levenshtein_distance
@@ -798,7 +820,7 @@ module ArelExtensions
798
820
  end
799
821
 
800
822
  def test_exists_in_subquery
801
- assert User.where(User.where(nil).exists).first
823
+ assert User.where(User.where(nil).arel.exists).first
802
824
  end
803
825
 
804
826
 
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'arelx_test_helper'
2
2
  require 'date'
3
3
 
4
4
  module ArelExtensions
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'arelx_test_helper'
2
2
 
3
3
  module ArelExtensions
4
4
  module WthAr
@@ -38,11 +38,12 @@ module ArelExtensions
38
38
  it "should import large set of data" do
39
39
  insert_manager = Arel::VERSION.to_i > 6 ? Arel::InsertManager.new().into(@table) : Arel::InsertManager.new(ActiveRecord::Base).into(@table)
40
40
  insert_manager.bulk_insert(@cols, @data)
41
- sql = insert_manager.to_sql
42
- sql.must_be_like %Q[INSERT INTO "users" ("id", "name", "comments", "created_at") 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']
41
+ _(insert_manager.to_sql)
42
+ .must_be_like %Q[INSERT INTO "users" ("id", "name", "comments", "created_at")
43
+ 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']
43
44
  end
44
45
 
45
46
  end
46
47
 
47
48
  end
48
- end
49
+ end
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'arelx_test_helper'
2
2
 
3
3
  module ArelExtensions
4
4
  module WthAr
@@ -61,4 +61,4 @@ module ArelExtensions
61
61
  end
62
62
 
63
63
  end
64
- end
64
+ end
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'arelx_test_helper'
2
2
  require 'date'
3
3
 
4
4
  module ArelExtensions
@@ -67,11 +67,9 @@ module ArelExtensions
67
67
  # Replace
68
68
  assert_equal "LucaX", User.where(:id => @lucas).select(@name.replace("s","X").as("res")).first.res
69
69
  assert_equal "replace", User.where(:id => @lucas).select(@name.replace(@name,"replace").as("res")).first.res
70
-
71
- #
72
70
  end
73
71
 
74
72
  end
75
73
 
76
74
  end
77
- end
75
+ end
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'arelx_test_helper'
2
2
  require 'date'
3
3
 
4
4
  module ArelExtensions
@@ -57,16 +57,12 @@ module ArelExtensions
57
57
  assert_equal 1, User.where((User.arel_table[:age] + "1").eq(6)).count
58
58
  assert_equal 1, User.where((User.arel_table[:age] + User.arel_table[:age]).eq(10)).count
59
59
 
60
-
61
-
62
60
  # Replace
63
61
  assert_equal "LucaX", User.where(:id => @lucas).select(@name.replace("s","X").as("res")).first.res
64
62
  assert_equal "replace", User.where(:id => @lucas).select(@name.replace(@name,"replace").as("res")).first.res
65
-
66
- #
67
63
  end
68
64
 
69
65
  end
70
66
 
71
67
  end
72
- end
68
+ end
@@ -0,0 +1,3 @@
1
+ module ArelExtensions
2
+ VERSION = "1.2.15".freeze
3
+ end
@@ -0,0 +1,3 @@
1
+ module ArelExtensions
2
+ VERSION = "2.0.11".freeze
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.5
4
+ version: 1.2.15
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: 2019-11-06 00:00:00.000000000 Z
13
+ date: 2020-09-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: arel
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '11'
63
+ version: 12.3.3
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '11'
70
+ version: 12.3.3
71
71
  description: Adds new features to Arel
72
72
  email:
73
73
  - yann.azoury@faveod.com
@@ -104,6 +104,9 @@ files:
104
104
  - gemfiles/rails5_0.gemfile
105
105
  - gemfiles/rails5_1_4.gemfile
106
106
  - gemfiles/rails5_2.gemfile
107
+ - gemfiles/rails6.gemfile
108
+ - gemspec_v2/arel_extensions-v2.gemspec
109
+ - generate_gems.sh
107
110
  - init/mssql.sql
108
111
  - init/mysql.sql
109
112
  - init/oracle.sql
@@ -174,8 +177,8 @@ files:
174
177
  - lib/arel_extensions/visitors/postgresql.rb
175
178
  - lib/arel_extensions/visitors/sqlite.rb
176
179
  - lib/arel_extensions/visitors/to_sql.rb
180
+ - test/arelx_test_helper.rb
177
181
  - test/database.yml
178
- - test/helper.rb
179
182
  - test/real_db_test.rb
180
183
  - test/support/alter_system_user_password.sql
181
184
  - test/support/create_oracle_enhanced_users.sql
@@ -192,6 +195,8 @@ files:
192
195
  - test/with_ar/test_math_sqlite.rb
193
196
  - test/with_ar/test_string_mysql.rb
194
197
  - test/with_ar/test_string_sqlite.rb
198
+ - version_v1.rb
199
+ - version_v2.rb
195
200
  homepage: https://github.com/Faveod/arel-extensions
196
201
  licenses:
197
202
  - MIT
@@ -1,18 +0,0 @@
1
- require 'rubygems'
2
- require 'minitest/autorun'
3
- require 'fileutils'
4
- require 'arel'
5
- require 'active_record'
6
-
7
- require 'arel_extensions'
8
-
9
- require 'support/fake_record'
10
- Arel::Table.engine = FakeRecord::Base.new
11
-
12
- $arel_silence_type_casting_deprecation = true
13
-
14
- class Object
15
- def must_be_like other
16
- gsub(/\s+/, ' ').strip.must_equal other.gsub(/\s+/, ' ').strip
17
- end
18
- end