arel_extensions 1.3.1 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +1 -2
  3. data/.github/workflows/ruby.yml +4 -4
  4. data/.rubocop.yml +25 -1
  5. data/Gemfile +10 -10
  6. data/README.md +24 -4
  7. data/Rakefile +4 -4
  8. data/TODO +0 -1
  9. data/arel_extensions.gemspec +12 -12
  10. data/gemfiles/rails3.gemfile +10 -10
  11. data/gemfiles/rails4.gemfile +13 -13
  12. data/gemfiles/rails5_0.gemfile +12 -12
  13. data/gemfiles/rails5_1_4.gemfile +12 -12
  14. data/gemfiles/rails5_2.gemfile +13 -13
  15. data/gemfiles/rails6.gemfile +11 -11
  16. data/gemfiles/rails6_1.gemfile +11 -11
  17. data/gemfiles/rails7.gemfile +7 -7
  18. data/gemspecs/arel_extensions-v1.gemspec +12 -12
  19. data/gemspecs/arel_extensions-v2.gemspec +11 -11
  20. data/init/mssql.sql +0 -0
  21. data/init/mysql.sql +0 -0
  22. data/init/oracle.sql +0 -0
  23. data/init/postgresql.sql +0 -0
  24. data/init/sqlite.sql +0 -0
  25. data/lib/arel_extensions/attributes.rb +2 -2
  26. data/lib/arel_extensions/boolean_functions.rb +2 -4
  27. data/lib/arel_extensions/common_sql_functions.rb +10 -10
  28. data/lib/arel_extensions/comparators.rb +14 -14
  29. data/lib/arel_extensions/date_duration.rb +7 -7
  30. data/lib/arel_extensions/helpers.rb +16 -13
  31. data/lib/arel_extensions/insert_manager.rb +1 -1
  32. data/lib/arel_extensions/math.rb +16 -18
  33. data/lib/arel_extensions/math_functions.rb +18 -18
  34. data/lib/arel_extensions/nodes/abs.rb +0 -0
  35. data/lib/arel_extensions/nodes/aggregate_function.rb +0 -0
  36. data/lib/arel_extensions/nodes/blank.rb +1 -1
  37. data/lib/arel_extensions/nodes/case.rb +4 -6
  38. data/lib/arel_extensions/nodes/cast.rb +3 -3
  39. data/lib/arel_extensions/nodes/ceil.rb +0 -0
  40. data/lib/arel_extensions/nodes/change_case.rb +0 -0
  41. data/lib/arel_extensions/nodes/coalesce.rb +0 -0
  42. data/lib/arel_extensions/nodes/collate.rb +9 -9
  43. data/lib/arel_extensions/nodes/concat.rb +2 -2
  44. data/lib/arel_extensions/nodes/date_diff.rb +6 -6
  45. data/lib/arel_extensions/nodes/duration.rb +0 -0
  46. data/lib/arel_extensions/nodes/find_in_set.rb +0 -0
  47. data/lib/arel_extensions/nodes/floor.rb +0 -0
  48. data/lib/arel_extensions/nodes/format.rb +1 -1
  49. data/lib/arel_extensions/nodes/formatted_number.rb +2 -2
  50. data/lib/arel_extensions/nodes/function.rb +21 -21
  51. data/lib/arel_extensions/nodes/is_null.rb +0 -0
  52. data/lib/arel_extensions/nodes/json.rb +7 -7
  53. data/lib/arel_extensions/nodes/length.rb +0 -0
  54. data/lib/arel_extensions/nodes/levenshtein_distance.rb +1 -1
  55. data/lib/arel_extensions/nodes/locate.rb +0 -0
  56. data/lib/arel_extensions/nodes/log10.rb +0 -0
  57. data/lib/arel_extensions/nodes/matches.rb +1 -1
  58. data/lib/arel_extensions/nodes/md5.rb +0 -0
  59. data/lib/arel_extensions/nodes/power.rb +0 -0
  60. data/lib/arel_extensions/nodes/rand.rb +0 -0
  61. data/lib/arel_extensions/nodes/repeat.rb +0 -0
  62. data/lib/arel_extensions/nodes/replace.rb +2 -2
  63. data/lib/arel_extensions/nodes/round.rb +0 -0
  64. data/lib/arel_extensions/nodes/soundex.rb +2 -2
  65. data/lib/arel_extensions/nodes/std.rb +0 -0
  66. data/lib/arel_extensions/nodes/substring.rb +0 -0
  67. data/lib/arel_extensions/nodes/sum.rb +0 -0
  68. data/lib/arel_extensions/nodes/then.rb +0 -0
  69. data/lib/arel_extensions/nodes/trim.rb +0 -0
  70. data/lib/arel_extensions/nodes/union.rb +4 -4
  71. data/lib/arel_extensions/nodes/union_all.rb +3 -3
  72. data/lib/arel_extensions/nodes/wday.rb +0 -0
  73. data/lib/arel_extensions/nodes.rb +0 -0
  74. data/lib/arel_extensions/null_functions.rb +0 -0
  75. data/lib/arel_extensions/predications.rb +10 -10
  76. data/lib/arel_extensions/railtie.rb +1 -1
  77. data/lib/arel_extensions/set_functions.rb +3 -3
  78. data/lib/arel_extensions/string_functions.rb +8 -8
  79. data/lib/arel_extensions/tasks.rb +2 -2
  80. data/lib/arel_extensions/version.rb +1 -1
  81. data/lib/arel_extensions/visitors/convert_format.rb +0 -0
  82. data/lib/arel_extensions/visitors/ibm_db.rb +19 -19
  83. data/lib/arel_extensions/visitors/mssql.rb +139 -118
  84. data/lib/arel_extensions/visitors/mysql.rb +145 -144
  85. data/lib/arel_extensions/visitors/oracle.rb +136 -128
  86. data/lib/arel_extensions/visitors/oracle12.rb +16 -16
  87. data/lib/arel_extensions/visitors/postgresql.rb +147 -136
  88. data/lib/arel_extensions/visitors/sqlite.rb +83 -85
  89. data/lib/arel_extensions/visitors/to_sql.rb +143 -148
  90. data/lib/arel_extensions/visitors.rb +7 -7
  91. data/lib/arel_extensions.rb +46 -32
  92. data/test/arelx_test_helper.rb +14 -14
  93. data/test/database.yml +5 -5
  94. data/test/real_db_test.rb +78 -78
  95. data/test/support/fake_record.rb +1 -1
  96. data/test/test_comparators.rb +5 -5
  97. data/test/visitors/test_bulk_insert_oracle.rb +4 -4
  98. data/test/visitors/test_bulk_insert_sqlite.rb +4 -4
  99. data/test/visitors/test_bulk_insert_to_sql.rb +4 -4
  100. data/test/visitors/test_oracle.rb +14 -14
  101. data/test/visitors/test_to_sql.rb +82 -82
  102. data/test/with_ar/all_agnostic_test.rb +415 -313
  103. data/test/with_ar/insert_agnostic_test.rb +17 -14
  104. data/test/with_ar/test_bulk_sqlite.rb +4 -4
  105. data/test/with_ar/test_math_sqlite.rb +12 -12
  106. data/test/with_ar/test_string_mysql.rb +20 -20
  107. data/test/with_ar/test_string_sqlite.rb +20 -20
  108. data/version_v1.rb +1 -1
  109. data/version_v2.rb +1 -1
  110. metadata +2 -9
  111. data/.travis/oracle/download.js +0 -152
  112. data/.travis/oracle/download.sh +0 -30
  113. data/.travis/oracle/download_ojdbc.js +0 -116
  114. data/.travis/oracle/install.sh +0 -34
  115. data/.travis/setup_accounts.sh +0 -9
  116. data/.travis/sqlite3/extension-functions.sh +0 -6
  117. data/.travis.yml +0 -193
@@ -4,11 +4,11 @@ require 'date'
4
4
  module ArelExtensions
5
5
  module WithAr
6
6
  class InsertManagerTest < Minitest::Test
7
- def setup_db
7
+ def connect_db
8
8
  ActiveRecord::Base.configurations = YAML.load_file('test/database.yml')
9
- if ENV['DB'] == 'oracle' && ((defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx") || (RUBY_PLATFORM == 'java')) # not supported
10
- @env_db = (RUBY_PLATFORM == 'java' ? "jdbc-sqlite" : 'sqlite')
11
- skip "Platform not supported"
9
+ if ENV['DB'] == 'oracle' && ((defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx') || (RUBY_PLATFORM == 'java')) # not supported
10
+ @env_db = (RUBY_PLATFORM == 'java' ? 'jdbc-sqlite' : 'sqlite')
11
+ skip "Platform not supported (DB: #{ENV['DB']}, RUBY_ENGINE: #{RUBY_ENGINE}, RUBY_PLATFORM: #{RUBY_PLATFORM})"
12
12
  else
13
13
  @env_db = ENV['DB']
14
14
  end
@@ -26,6 +26,9 @@ module ArelExtensions
26
26
  @cnx.execute(sql) rescue $stderr << "can't create functions\n"
27
27
  end
28
28
  end
29
+ end
30
+
31
+ def setup_db
29
32
  @cnx.drop_table(:user_tests) rescue nil
30
33
  @cnx.create_table :user_tests do |t|
31
34
  t.column :age, :integer
@@ -33,7 +36,7 @@ module ArelExtensions
33
36
  t.column :comments, :text
34
37
  t.column :created_at, :date
35
38
  t.column :updated_at, :datetime
36
- t.column :score, :decimal, :precision => 20, :scale => 10
39
+ t.column :score, :decimal, precision: 20, scale: 10
37
40
  end
38
41
  if @env_db == 'oracle'
39
42
  @cnx.execute(%q[CREATE OR REPLACE trigger user_tests_trg
@@ -52,17 +55,18 @@ END;])
52
55
  end
53
56
 
54
57
  def setup
58
+ connect_db
55
59
  setup_db
56
60
  @table = Arel::Table.new(:user_tests)
57
61
  @cols = ['id', 'name', 'comments', 'created_at']
58
62
  @data = [
59
- [23, 'nom1', "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.", '2016-01-01'],
60
- [25, 'nom2', "sdfdsfdsfsdf", '2016-01-02']
63
+ [23, 'nom1', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.', '2016-01-01'],
64
+ [25, 'nom2', 'sdfdsfdsfsdf', '2016-01-02']
61
65
  ]
62
66
  @cols2 = ['name', 'comments', 'created_at']
63
67
  @data2 = [
64
- ['nom3', "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.", '2016-01-01'],
65
- ['nom4', "sdfdsfdsfsdf", '2016-01-04']
68
+ ['nom3', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.', '2016-01-01'],
69
+ ['nom4', 'sdfdsfdsfsdf', '2016-01-04']
66
70
  ]
67
71
  end
68
72
 
@@ -72,15 +76,14 @@ END;])
72
76
 
73
77
  # Math Functions
74
78
  def test_bulk_insert
75
- insert_manager = Arel::VERSION.to_i > 6 ? Arel::InsertManager.new().into(@table) : Arel::InsertManager.new(Arel::Table.engine).into(@table)
79
+ insert_manager = Arel::VERSION.to_i > 6 ? Arel::InsertManager.new.into(@table) : Arel::InsertManager.new(Arel::Table.engine).into(@table)
76
80
  insert_manager.bulk_insert(@cols, @data)
77
81
  @cnx.execute(insert_manager.to_sql)
78
- assert_equal 2, User.count, "insertions failed"
79
- insert_manager = Arel::VERSION.to_i > 6 ? Arel::InsertManager.new().into(@table) : Arel::InsertManager.new(Arel::Table.engine).into(@table)
82
+ assert_equal 2, User.count, 'insertions failed'
83
+ insert_manager = Arel::VERSION.to_i > 6 ? Arel::InsertManager.new.into(@table) : Arel::InsertManager.new(Arel::Table.engine).into(@table)
80
84
  insert_manager.bulk_insert(@cols2, @data2)
81
85
  @cnx.execute(insert_manager.to_sql)
82
- assert_equal 4, User.count, "insertions failed"
83
-
86
+ assert_equal 4, User.count, 'insertions failed'
84
87
  end
85
88
  end
86
89
  end
@@ -29,16 +29,16 @@ module ArelExtensions
29
29
  @table = Arel::Table.new(:users)
30
30
  @cols = ['id', 'name', 'comments', 'created_at']
31
31
  @data = [
32
- [23, 'nom1', "sdfdsfdsfsdf", '2016-01-01'],
33
- [25, 'nom2', "sdfdsfdsfsdf", '2016-01-01']
32
+ [23, 'nom1', 'sdfdsfdsfsdf', '2016-01-01'],
33
+ [25, 'nom2', 'sdfdsfdsfsdf', '2016-01-01']
34
34
  ]
35
35
  end
36
36
  after do
37
37
  @cnx.drop_table(:users)
38
38
  end
39
39
 
40
- it "should import large set of data" do
41
- insert_manager = Arel::VERSION.to_i > 6 ? Arel::InsertManager.new().into(@table) : Arel::InsertManager.new(ActiveRecord::Base).into(@table)
40
+ it 'should import large set of data' do
41
+ insert_manager = Arel::VERSION.to_i > 6 ? Arel::InsertManager.new.into(@table) : Arel::InsertManager.new(ActiveRecord::Base).into(@table)
42
42
  insert_manager.bulk_insert(@cols, @data)
43
43
  _(insert_manager.to_sql)
44
44
  .must_be_like %Q[INSERT INTO "users" ("id", "name", "comments", "created_at")
@@ -28,15 +28,15 @@ module ArelExtensions
28
28
  end
29
29
  class User < ActiveRecord::Base
30
30
  end
31
- d = Date.new(2016, 5,23)
32
- User.create :age => 5, :name => "Lucas", :created_at => d, :score => 20.16
33
- User.create :age => 15, :name => "Sophie", :created_at => d, :score => 20.16
34
- User.create :age => 20, :name => "Camille", :created_at => d, :score => 20.16
35
- User.create :age => 21, :name => "Arthur", :created_at => d, :score => 65.62
36
- User.create :age => 23, :name => "Myung", :created_at => d, :score => 20.16
37
- @laure = User.create :age => 25, :name => "Laure", :created_at => d, :score =>20.16
38
- User.create :age => nil, :name => "Test", :created_at => d, :score => 1.62
39
- @neg = User.create :age => -20, :name => "Negatif", :created_at => d, :score => 0.17
31
+ d = Date.new(2016, 5, 23)
32
+ User.create age: 5, name: 'Lucas', created_at: d, score: 20.16
33
+ User.create age: 15, name: 'Sophie', created_at: d, score: 20.16
34
+ User.create age: 20, name: 'Camille', created_at: d, score: 20.16
35
+ User.create age: 21, name: 'Arthur', created_at: d, score: 65.62
36
+ User.create age: 23, name: 'Myung', created_at: d, score: 20.16
37
+ @laure = User.create age: 25, name: 'Laure', created_at: d, score: 20.16
38
+ User.create age: nil, name: 'Test', created_at: d, score: 1.62
39
+ @neg = User.create age: -20, name: 'Negatif', created_at: d, score: 0.17
40
40
  @table = Arel::Table.new(:users)
41
41
  @age = @table[:age]
42
42
  end
@@ -45,10 +45,10 @@ module ArelExtensions
45
45
  @cnx.drop_table(:products)
46
46
  end
47
47
 
48
- it "should do maths" do
48
+ it 'should do maths' do
49
49
  # ABS
50
- assert_equal 20, User.where(:id => @neg.id).select(@age.abs.as("res")).first.res
51
- assert_equal 14, User.where(:id => @laure.id).select((@age - 39).abs.as("res")).first.res
50
+ assert_equal 20, User.where(id: @neg.id).select(@age.abs.as('res')).first.res
51
+ assert_equal 14, User.where(id: @laure.id).select((@age - 39).abs.as('res')).first.res
52
52
 
53
53
  # CEIL # require extensions
54
54
 
@@ -35,16 +35,16 @@ module ArelExtensions
35
35
  end
36
36
  class User < ActiveRecord::Base
37
37
  end
38
- d = Date.new(2016, 5,23)
39
- @lucas = User.create :age => 5, :name => "Lucas", :created_at => d, :score => 20.16
40
- sophie = User.create :age => 15, :name => "Sophie", :created_at => d, :score => 20.16
41
- @sophie = User.where(:id => sophie.id)
42
- User.create :age => 20, :name => "Camille", :created_at => d, :score => 20.16
43
- User.create :age => 21, :name => "Arthur", :created_at => d, :score => 65.62
44
- User.create :age => 23, :name => "Myung", :created_at => d, :score => 20.16
45
- @laure = User.create :age => 25, :name => "Laure", :created_at => d, :score =>20.16
46
- User.create :age => nil, :name => "Test", :created_at => d, :score => 1.62
47
- @neg = User.create :age => -20, :name => "Negatif", :created_at => d, :score => 0.17
38
+ d = Date.new(2016, 5, 23)
39
+ @lucas = User.create age: 5, name: 'Lucas', created_at: d, score: 20.16
40
+ sophie = User.create age: 15, name: 'Sophie', created_at: d, score: 20.16
41
+ @sophie = User.where(id: sophie.id)
42
+ User.create age: 20, name: 'Camille', created_at: d, score: 20.16
43
+ User.create age: 21, name: 'Arthur', created_at: d, score: 65.62
44
+ User.create age: 23, name: 'Myung', created_at: d, score: 20.16
45
+ @laure = User.create age: 25, name: 'Laure', created_at: d, score: 20.16
46
+ User.create age: nil, name: 'Test', created_at: d, score: 1.62
47
+ @neg = User.create age: -20, name: 'Negatif', created_at: d, score: 0.17
48
48
  @table = Arel::Table.new(:users)
49
49
  @name = @table[:name]
50
50
  end
@@ -52,23 +52,23 @@ module ArelExtensions
52
52
  @cnx.drop_table(:users)
53
53
  end
54
54
 
55
- it "should do string operations" do
55
+ it 'should do string operations' do
56
56
  # concat
57
57
  d = Date.new(1997, 6, 15)
58
- assert_equal "SophiePhan", @sophie.select((@name + "Phan").as("res")).first.res
59
- assert_equal "Sophie2", @sophie.select((@name + 2).as("res")).first.res
60
- assert_equal "Sophie1997-06-15", @sophie.select((@name + d).as("res")).first.res
61
- assert_equal "Sophie15", @sophie.select((User.arel_table[:name] + User.arel_table[:age]).as("res")).first.res
62
- assert_equal "SophieSophie", @sophie.select((User.arel_table[:name] + User.arel_table[:name]).as("res")).first.res
63
- assert_equal "Sophie2016-05-23", @sophie.select((User.arel_table[:name] + User.arel_table[:created_at]).as("res")).first.res
58
+ assert_equal 'SophiePhan', @sophie.select((@name + 'Phan').as('res')).first.res
59
+ assert_equal 'Sophie2', @sophie.select((@name + 2).as('res')).first.res
60
+ assert_equal 'Sophie1997-06-15', @sophie.select((@name + d).as('res')).first.res
61
+ assert_equal 'Sophie15', @sophie.select((User.arel_table[:name] + User.arel_table[:age]).as('res')).first.res
62
+ assert_equal 'SophieSophie', @sophie.select((User.arel_table[:name] + User.arel_table[:name]).as('res')).first.res
63
+ assert_equal 'Sophie2016-05-23', @sophie.select((User.arel_table[:name] + User.arel_table[:created_at]).as('res')).first.res
64
64
  # concat Integer
65
65
  assert_equal 1, User.where((User.arel_table[:age] + 10).eq(33)).count
66
- assert_equal 1, User.where((User.arel_table[:age] + "1").eq(6)).count
66
+ assert_equal 1, User.where((User.arel_table[:age] + '1').eq(6)).count
67
67
  assert_equal 1, User.where((User.arel_table[:age] + User.arel_table[:age]).eq(10)).count
68
68
 
69
69
  # Replace
70
- assert_equal "LucaX", User.where(:id => @lucas).select(@name.replace("s","X").as("res")).first.res
71
- assert_equal "replace", User.where(:id => @lucas).select(@name.replace(@name,"replace").as("res")).first.res
70
+ assert_equal 'LucaX', User.where(id: @lucas).select(@name.replace('s', 'X').as('res')).first.res
71
+ assert_equal 'replace', User.where(id: @lucas).select(@name.replace(@name, 'replace').as('res')).first.res
72
72
  end
73
73
  end
74
74
  end
@@ -28,16 +28,16 @@ module ArelExtensions
28
28
  end
29
29
  class User < ActiveRecord::Base
30
30
  end
31
- d = Date.new(2016, 5,23)
32
- @lucas = User.create! :age => 5, :name => "Lucas", :created_at => d, :score => 20.16
33
- sophie = User.create :age => 15, :name => "Sophie", :created_at => d, :score => 20.16
34
- @sophie = User.where(:id => sophie.id)
35
- User.create! :age => 20, :name => "Camille", :created_at => d, :score => 20.16
36
- User.create! :age => 21, :name => "Arthur", :created_at => d, :score => 65.62
37
- User.create! :age => 23, :name => "Myung", :created_at => d, :score => 20.16
38
- @laure = User.create :age => 25, :name => "Laure", :created_at => d, :score =>20.16
39
- User.create! :age => nil, :name => "Test", :created_at => d, :score => 1.62
40
- @neg = User.create :age => -20, :name => "Negatif", :created_at => d, :score => 0.17
31
+ d = Date.new(2016, 5, 23)
32
+ @lucas = User.create! age: 5, name: 'Lucas', created_at: d, score: 20.16
33
+ sophie = User.create age: 15, name: 'Sophie', created_at: d, score: 20.16
34
+ @sophie = User.where(id: sophie.id)
35
+ User.create! age: 20, name: 'Camille', created_at: d, score: 20.16
36
+ User.create! age: 21, name: 'Arthur', created_at: d, score: 65.62
37
+ User.create! age: 23, name: 'Myung', created_at: d, score: 20.16
38
+ @laure = User.create age: 25, name: 'Laure', created_at: d, score: 20.16
39
+ User.create! age: nil, name: 'Test', created_at: d, score: 1.62
40
+ @neg = User.create age: -20, name: 'Negatif', created_at: d, score: 0.17
41
41
  @table = Arel::Table.new(:users)
42
42
  @name = @table[:name]
43
43
  end
@@ -45,23 +45,23 @@ module ArelExtensions
45
45
  @cnx.drop_table(:users)
46
46
  end
47
47
 
48
- it "should do string operations" do
48
+ it 'should do string operations' do
49
49
  # concat
50
50
  d = Date.new(1997, 6, 15)
51
- assert_equal "SophiePhan", @sophie.select((@name + "Phan").as("res")).first.res
52
- assert_equal "Sophie2", @sophie.select((@name + 2).as("res")).first.res
53
- assert_equal "Sophie1997-06-15", @sophie.select((@name + d).as("res")).first.res
54
- assert_equal "Sophie15", @sophie.select((User.arel_table[:name] + User.arel_table[:age]).as("res")).first.res
55
- assert_equal "SophieSophie", @sophie.select((User.arel_table[:name] + User.arel_table[:name]).as("res")).first.res
56
- assert_equal "Sophie2016-05-23", @sophie.select((User.arel_table[:name] + User.arel_table[:created_at]).as("res")).first.res
51
+ assert_equal 'SophiePhan', @sophie.select((@name + 'Phan').as('res')).first.res
52
+ assert_equal 'Sophie2', @sophie.select((@name + 2).as('res')).first.res
53
+ assert_equal 'Sophie1997-06-15', @sophie.select((@name + d).as('res')).first.res
54
+ assert_equal 'Sophie15', @sophie.select((User.arel_table[:name] + User.arel_table[:age]).as('res')).first.res
55
+ assert_equal 'SophieSophie', @sophie.select((User.arel_table[:name] + User.arel_table[:name]).as('res')).first.res
56
+ assert_equal 'Sophie2016-05-23', @sophie.select((User.arel_table[:name] + User.arel_table[:created_at]).as('res')).first.res
57
57
  # concat Integer
58
58
  assert_equal 1, User.where((User.arel_table[:age] + 10).eq(33)).count
59
- assert_equal 1, User.where((User.arel_table[:age] + "1").eq(6)).count
59
+ assert_equal 1, User.where((User.arel_table[:age] + '1').eq(6)).count
60
60
  assert_equal 1, User.where((User.arel_table[:age] + User.arel_table[:age]).eq(10)).count
61
61
 
62
62
  # Replace
63
- assert_equal "LucaX", User.where(:id => @lucas).select(@name.replace("s","X").as("res")).first.res
64
- assert_equal "replace", User.where(:id => @lucas).select(@name.replace(@name,"replace").as("res")).first.res
63
+ assert_equal 'LucaX', User.where(id: @lucas).select(@name.replace('s', 'X').as('res')).first.res
64
+ assert_equal 'replace', User.where(id: @lucas).select(@name.replace(@name, 'replace').as('res')).first.res
65
65
  end
66
66
  end
67
67
  end
data/version_v1.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "1.3.1".freeze
2
+ VERSION = '1.3.4'.freeze
3
3
  end
data/version_v2.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "2.1.1".freeze
2
+ VERSION = '2.1.4'.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.3.1
4
+ version: 1.3.4
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: 2022-03-03 00:00:00.000000000 Z
13
+ date: 2022-03-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: arel
@@ -84,13 +84,6 @@ files:
84
84
  - ".github/workflows/ruby.yml"
85
85
  - ".gitignore"
86
86
  - ".rubocop.yml"
87
- - ".travis.yml"
88
- - ".travis/oracle/download.js"
89
- - ".travis/oracle/download.sh"
90
- - ".travis/oracle/download_ojdbc.js"
91
- - ".travis/oracle/install.sh"
92
- - ".travis/setup_accounts.sh"
93
- - ".travis/sqlite3/extension-functions.sh"
94
87
  - Gemfile
95
88
  - MIT-LICENSE.txt
96
89
  - README.md
@@ -1,152 +0,0 @@
1
- // vim: set et sw=2 ts=2:
2
- "use strict";
3
- var env = process.env;
4
- var url = require('url');
5
- var Promise = require('bluebird');
6
- var Phantom = Promise.promisifyAll(require('node-phantom-simple'));
7
-
8
- var login = {
9
- begin: url.parse(env['ORACLE_LOGIN_BEGIN'] || "https://www.oracle.com/webapps/redirect/signon?nexturl=https://www.oracle.com/favicon.ico"),
10
- end: url.parse(env['ORCALE_LOGIN_END'] || "https://www.oracle.com/favicon.ico"),
11
- };
12
- delete env['ORACLE_LOGIN_BEGIN'];
13
- delete env['ORACLE_LOGIN_END'];
14
-
15
- var credentials = Object.keys(env)
16
- .filter(function (key) { return key.indexOf('ORACLE_LOGIN_') == 0 })
17
- .map(function (key) { return [key.substr(13), env[key]] });
18
-
19
- if (credentials.length <= 0) {
20
- console.error("Missing ORACLE_LOGIN environment variables!");
21
- process.exit(1);
22
- }
23
-
24
- Phantom.createAsync({ parameters: { 'ssl-protocol': 'tlsv1' } }).then(function (browser) {
25
- browser = Promise.promisifyAll(browser, { suffix: 'Promise' });
26
- browser.addCookie({'name': 'oraclelicense', 'value': "accept-" + env['ORACLE_COOKIE'] + "-cookie", 'domain': '.oracle.com' });
27
-
28
- // Open a tab, configure it
29
- return browser.createPagePromise().then(function (page) {
30
- page = Promise.promisifyAll(page, { suffix: 'Promise' });
31
-
32
- var received = "";
33
- page.onNavigationRequested = function () { console.info("%s %j", (new Date()).toISOString(), arguments["0"]); };
34
- page.onResourceError = console.error.bind(console);
35
- page.onResourceReceived = function (response) { if (response.stage == "end") received = response.url; };
36
- page.set('settings.loadImages', false);
37
-
38
- return page
39
- .setPromise('settings.userAgent', env['USER_AGENT']) // PhantomJS configures the UA per tab
40
-
41
- // Begin login, wait for the login page
42
- .then(function () {
43
- return page.openPromise(login.begin.href).then(function (status) {
44
- if (status != 'success') throw "Unable to connect to " + login.begin.host;
45
-
46
- return new Promise(function (resolve, reject) {
47
- var deadline = Date.now() + 6000;
48
- var interval = 100;
49
-
50
- var check = function () {
51
- if (deadline < Date.now()) return reject("Timeout waiting for form");
52
-
53
- page.evaluate(function () {
54
- return window['jQuery'] && document.querySelectorAll('input[type=password]').length;
55
- }, function (err, result) {
56
- if (result) { resolve(); } else { setTimeout(check, interval); }
57
- });
58
- };
59
-
60
- check();
61
- });
62
- })
63
- .tapCatch(function (err) {
64
- return page.getPromise('plainText').then(function (text) {
65
- console.error("Unable to load login page. Last response was:\n" + text);
66
- });
67
- });
68
- })
69
-
70
- // Submit the login form
71
- .then(function () {
72
- return page.evaluatePromise(function (credentials) {
73
- var $form = jQuery(document.forms[0]);
74
- return credentials.filter(function (tuple) {
75
- return $form.find("[name='"+tuple[0]+"']").val(tuple[1]).length == 0;
76
- })
77
- .map(function (tuple) { return tuple[0]; });
78
- }, credentials)
79
- .then(function (unapplied) {
80
- if (unapplied.length > 0) {
81
- console.warn("Unable to use all ORACLE_LOGIN environment variables: %j", unapplied);
82
- }
83
- return page.evaluatePromise(function () {
84
- jQuery(function () { document.forms[0].submit(); });
85
- });
86
- });
87
- })
88
-
89
- // Wait for login result
90
- .then(function () {
91
- return new Promise(function (resolve, reject) {
92
- var deadline = Date.now() + 6000;
93
- var interval = 100;
94
-
95
- var check = function () {
96
- if (deadline < Date.now()) return reject("Timeout waiting for " + login.end.href);
97
- if (received == login.end.href) { resolve(); } else { setTimeout(check, interval); }
98
- };
99
-
100
- check();
101
- })
102
- .tapCatch(function (err) {
103
- return page.getPromise('plainText').then(function (text) {
104
- console.error("Unable to load login result. Last response was:\n" + text);
105
- });
106
- });
107
- })
108
-
109
- // Export cookies for cURL
110
- .then(function () {
111
- return browser.getPromise('cookies').then(function (cookies) {
112
- var data = "";
113
- for (var i = 0; i < cookies.length; ++i) {
114
- var cookie = cookies[i];
115
- data += cookie.domain + "\tTRUE\t" + cookie.path + "\t"
116
- + (cookie.secure ? "TRUE" : "FALSE") + "\t0\t"
117
- + cookie.name + "\t" + cookie.value + "\n";
118
- }
119
- return Promise.promisify(require('fs').writeFile)(env['COOKIES'], data);
120
- });
121
- })
122
-
123
- // Download file using cURL
124
- .then(function () {
125
- return browser.exitPromise().then(function () {
126
- var cmd = ['curl', [
127
- '--cookie', env['COOKIES'],
128
- '--cookie-jar', env['COOKIES'],
129
- '--location',
130
- '--output', env['ORACLE_DOWNLOAD_FILE'],
131
- '--user-agent', env['USER_AGENT'],
132
- "https://edelivery.oracle.com/akam/otn/linux/" + env['ORACLE_FILE']
133
- ]];
134
-
135
- console.info("Executing %j", cmd);
136
-
137
- var child_process = require('child_process');
138
- var child = child_process.spawn.apply(child_process, cmd.concat({ stdio: [0, 1, 2] }));
139
- child.on('exit', process.exit);
140
- });
141
- })
142
- .catch(function (err) {
143
- console.error(err);
144
- browser.on('exit', function () { process.exit(1); });
145
- browser.exit();
146
- });
147
- });
148
- })
149
- .catch(function (err) {
150
- console.error(err);
151
- process.exit(1);
152
- });
@@ -1,30 +0,0 @@
1
- #!/bin/sh -e
2
- # vim: set et sw=2 ts=2:
3
-
4
- [ -n "$ORACLE_COOKIE" ] || { echo "Missing ORACLE_COOKIE environment variable!"; exit 1; }
5
- [ -n "$ORACLE_FILE" ] || { echo "Missing ORACLE_FILE environment variable!"; exit 1; }
6
-
7
- ORACLE_DOWNLOAD_FILE="$(basename "$ORACLE_FILE")"
8
-
9
- if [ -n "$ORACLE_DOWNLOAD_DIR" ]; then
10
- mkdir -p "$ORACLE_DOWNLOAD_DIR"
11
- ORACLE_DOWNLOAD_FILE="$(readlink -f "$ORACLE_DOWNLOAD_DIR")/$ORACLE_DOWNLOAD_FILE"
12
- fi
13
-
14
- if [ "${*#*--unless-exists}" != "$*" ] && [ -f "$ORACLE_DOWNLOAD_FILE" ]; then
15
- exit 0
16
- fi
17
-
18
- cd "$(dirname "$(readlink -f "$0")")"
19
-
20
- echo "PhantomJS version $(phantomjs --version)"
21
- npm install bluebird node-phantom-simple
22
-
23
- export ORACLE_DOWNLOAD_FILE
24
- export COOKIES='cookies.txt'
25
- export USER_AGENT='Mozilla/5.0'
26
-
27
- echo > "$COOKIES"
28
- chmod 600 "$COOKIES"
29
-
30
- exec node download.js
@@ -1,116 +0,0 @@
1
- // vim: set et sw=2 ts=2:
2
- "use strict";
3
- var env = process.env;
4
- var Promise = require('bluebird');
5
- var Phantom = Promise.promisifyAll(require('node-phantom-simple'));
6
- var PhantomError = require('node-phantom-simple/headless_error');
7
-
8
- var credentials = Object.keys(env)
9
- .filter(function (key) { return key.indexOf('ORACLE_LOGIN_') == 0 })
10
- .map(function (key) { return [key.substr(13), env[key]] });
11
-
12
- if (credentials.length <= 0) {
13
- console.error("Missing ORACLE_LOGIN environment variables!");
14
- process.exit(1);
15
- }
16
-
17
- Phantom.createAsync({ parameters: { 'ssl-protocol': 'tlsv1' } }).then(function (browser) {
18
- browser = Promise.promisifyAll(browser, { suffix: 'Promise' });
19
-
20
- // Configure the browser, open a tab
21
- return browser
22
- .addCookiePromise({'name': 'oraclelicense', 'value': "accept-" + env['ORACLE_COOKIE'] + "-cookie", 'domain': '.oracle.com' })
23
- .then(function () {
24
- return browser.createPagePromise();
25
- })
26
- .then(function (page) {
27
- page = Promise.promisifyAll(page, { suffix: 'Promise' });
28
-
29
- // Configure the tab
30
- page.onResourceError = console.error.bind(console);
31
- return page
32
- .setPromise('settings.userAgent', env['USER_AGENT']) // PhantomJS configures the UA per tab
33
-
34
- // Request the file, wait for the login page
35
- .then(function () {
36
- return page.openPromise("https://edelivery.oracle.com/akam/otn/linux/" + env['ORACLE_FILE']).then(function (status) {
37
- if (status != 'success') throw "Unable to connect to oracle.com";
38
- return page.waitForSelectorPromise('input[type=password]', 5000);
39
- })
40
- .catch(PhantomError, function (err) {
41
- return page.getPromise('plainText').then(function (text) {
42
- console.error("Unable to load login page. Last response was:\n" + text);
43
- throw err;
44
- });
45
- });
46
- })
47
-
48
- // Export cookies for cURL
49
- .then(function () {
50
- return page.getPromise('cookies').then(function (cookies) {
51
- var data = "";
52
- for (var i = 0; i < cookies.length; ++i) {
53
- var cookie = cookies[i];
54
- data += cookie.domain + "\tTRUE\t" + cookie.path + "\t"
55
- + (cookie.secure ? "TRUE" : "FALSE") + "\t0\t"
56
- + cookie.name + "\t" + cookie.value + "\n";
57
- }
58
- return Promise.promisifyAll(require('fs')).writeFileAsync(env['COOKIES'], data);
59
- });
60
- })
61
-
62
- // Submit the login form using cURL
63
- .then(function () {
64
- return page.evaluatePromise(function () {
65
- var $form = jQuery(document.forms[0]);
66
- return {
67
- action: $form.prop('action'),
68
- data: $form.serialize()
69
- };
70
- })
71
- .then(function (form) {
72
- return browser.exitPromise().then(function () {
73
- var unapplied = credentials.filter(function (tuple) {
74
- var applied = false;
75
- form.data = form.data.replace(tuple[0] + '=', function (name) {
76
- applied = true;
77
- return name + encodeURIComponent(tuple[1]);
78
- });
79
- return !applied;
80
- })
81
- .map(function (tuple) { return tuple[0] });
82
-
83
- if (unapplied.length > 0) {
84
- console.warn("Unable to use all ORACLE_LOGIN environment variables: %j", unapplied);
85
- }
86
-
87
- var cmd = ['curl', [
88
- '--cookie', env['COOKIES'],
89
- '--cookie-jar', env['COOKIES'],
90
- '--data', '@-',
91
- '--location',
92
- '--output', require('path').basename('ojdbc6.jar'),
93
- '--user-agent', env['USER_AGENT'],
94
- env['ORACLE_OJDBC_URL']
95
- ]];
96
-
97
- console.info("Executing %j", cmd);
98
-
99
- var child_process = require('child_process');
100
- var child = child_process.spawn.apply(child_process, cmd.concat({ stdio: ['pipe', 1, 2] }));
101
- child.on('exit', process.exit);
102
- child.stdin.end(form.data);
103
- });
104
- });
105
- })
106
- .catch(function (err) {
107
- console.error(err);
108
- browser.on('exit', function () { process.exit(1); });
109
- browser.exit();
110
- });
111
- });
112
- })
113
- .catch(function (err) {
114
- console.error(err);
115
- process.exit(1);
116
- });
@@ -1,34 +0,0 @@
1
- #!/bin/sh -e
2
- # vim: set et sw=2 ts=2:
3
-
4
- [ -z "$ORACLE_DOWNLOAD_DIR" ] || ORACLE_DOWNLOAD_DIR="$(readlink -f "$ORACLE_DOWNLOAD_DIR")/"
5
- [ -n "$ORACLE_FILE" ] || { echo "Missing ORACLE_FILE environment variable!"; exit 1; }
6
- [ -n "$ORACLE_HOME" ] || { echo "Missing ORACLE_HOME environment variable!"; exit 1; }
7
-
8
- ORACLE_RPM="$(basename "$ORACLE_FILE" .zip)"
9
-
10
- cd "$(dirname "$(readlink -f "$0")")"
11
-
12
- dpkg -s bc libaio1 rpm unzip > /dev/null 2>&1 ||
13
- ( sudo apt-get -qq update && sudo apt-get --no-install-recommends -qq install bc libaio1 rpm unzip )
14
-
15
- df -B1 /dev/shm | awk 'END { if ($1 != "shmfs" && $1 != "tmpfs" || $2 < 2147483648) exit 1 }' ||
16
- ( sudo rm -r /dev/shm && sudo mkdir /dev/shm && sudo mount -t tmpfs shmfs -o size=2G /dev/shm )
17
-
18
- test -f /sbin/chkconfig ||
19
- ( echo '#!/bin/sh' | sudo tee /sbin/chkconfig > /dev/null && sudo chmod u+x /sbin/chkconfig )
20
-
21
- test -d /var/lock/subsys || sudo mkdir /var/lock/subsys
22
-
23
- unzip -j "${ORACLE_DOWNLOAD_DIR}$(basename "$ORACLE_FILE")" "*/$ORACLE_RPM"
24
- sudo rpm --install --nodeps --nopre "$ORACLE_RPM"
25
-
26
- echo 'OS_AUTHENT_PREFIX=""' | sudo tee -a "$ORACLE_HOME/config/scripts/init.ora" > /dev/null
27
- sudo usermod -aG dba $USER
28
-
29
- ( echo ; echo ; echo travis ; echo travis ; echo n ) | sudo AWK='/usr/bin/awk' /etc/init.d/oracle-xe configure
30
-
31
- "$ORACLE_HOME/bin/sqlplus" -L -S / AS SYSDBA <<SQL
32
- CREATE USER $USER IDENTIFIED EXTERNALLY;
33
- GRANT CONNECT, RESOURCE TO $USER;
34
- SQL