arel_extensions 1.2.25 → 2.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -7
  3. data/.travis.yml +91 -61
  4. data/Gemfile +20 -15
  5. data/README.md +12 -17
  6. data/Rakefile +29 -40
  7. data/appveyor.yml +1 -1
  8. data/arel_extensions.gemspec +3 -3
  9. data/functions.html +3 -3
  10. data/gemfiles/rails3.gemfile +9 -9
  11. data/gemfiles/rails4.gemfile +13 -13
  12. data/gemfiles/rails5_0.gemfile +13 -13
  13. data/gemfiles/rails5_1_4.gemfile +13 -13
  14. data/gemfiles/rails5_2.gemfile +13 -13
  15. data/init/mssql.sql +4 -4
  16. data/init/mysql.sql +38 -38
  17. data/init/postgresql.sql +21 -21
  18. data/lib/arel_extensions/attributes.rb +1 -0
  19. data/lib/arel_extensions/boolean_functions.rb +14 -55
  20. data/lib/arel_extensions/common_sql_functions.rb +8 -7
  21. data/lib/arel_extensions/comparators.rb +15 -14
  22. data/lib/arel_extensions/date_duration.rb +5 -4
  23. data/lib/arel_extensions/insert_manager.rb +16 -17
  24. data/lib/arel_extensions/math.rb +12 -11
  25. data/lib/arel_extensions/math_functions.rb +22 -29
  26. data/lib/arel_extensions/nodes/abs.rb +1 -0
  27. data/lib/arel_extensions/nodes/blank.rb +1 -0
  28. data/lib/arel_extensions/nodes/case.rb +8 -11
  29. data/lib/arel_extensions/nodes/cast.rb +2 -4
  30. data/lib/arel_extensions/nodes/ceil.rb +1 -1
  31. data/lib/arel_extensions/nodes/change_case.rb +0 -0
  32. data/lib/arel_extensions/nodes/coalesce.rb +3 -2
  33. data/lib/arel_extensions/nodes/collate.rb +2 -1
  34. data/lib/arel_extensions/nodes/concat.rb +16 -7
  35. data/lib/arel_extensions/nodes/date_diff.rb +13 -10
  36. data/lib/arel_extensions/nodes/duration.rb +3 -0
  37. data/lib/arel_extensions/nodes/find_in_set.rb +1 -0
  38. data/lib/arel_extensions/nodes/floor.rb +1 -1
  39. data/lib/arel_extensions/nodes/format.rb +8 -34
  40. data/lib/arel_extensions/nodes/formatted_number.rb +23 -22
  41. data/lib/arel_extensions/nodes/function.rb +16 -25
  42. data/lib/arel_extensions/nodes/json.rb +36 -43
  43. data/lib/arel_extensions/nodes/length.rb +0 -5
  44. data/lib/arel_extensions/nodes/levenshtein_distance.rb +0 -0
  45. data/lib/arel_extensions/nodes/locate.rb +1 -0
  46. data/lib/arel_extensions/nodes/log10.rb +2 -1
  47. data/lib/arel_extensions/nodes/matches.rb +6 -4
  48. data/lib/arel_extensions/nodes/md5.rb +1 -0
  49. data/lib/arel_extensions/nodes/power.rb +5 -5
  50. data/lib/arel_extensions/nodes/rand.rb +1 -0
  51. data/lib/arel_extensions/nodes/repeat.rb +4 -2
  52. data/lib/arel_extensions/nodes/replace.rb +6 -22
  53. data/lib/arel_extensions/nodes/round.rb +6 -5
  54. data/lib/arel_extensions/nodes/soundex.rb +15 -15
  55. data/lib/arel_extensions/nodes/std.rb +21 -18
  56. data/lib/arel_extensions/nodes/substring.rb +16 -8
  57. data/lib/arel_extensions/nodes/then.rb +0 -0
  58. data/lib/arel_extensions/nodes/trim.rb +5 -3
  59. data/lib/arel_extensions/nodes/union.rb +5 -2
  60. data/lib/arel_extensions/nodes/union_all.rb +3 -0
  61. data/lib/arel_extensions/nodes/wday.rb +4 -0
  62. data/lib/arel_extensions/nodes.rb +1 -1
  63. data/lib/arel_extensions/null_functions.rb +7 -5
  64. data/lib/arel_extensions/predications.rb +34 -35
  65. data/lib/arel_extensions/railtie.rb +5 -5
  66. data/lib/arel_extensions/set_functions.rb +4 -2
  67. data/lib/arel_extensions/string_functions.rb +23 -52
  68. data/lib/arel_extensions/tasks.rb +5 -5
  69. data/lib/arel_extensions/version.rb +1 -1
  70. data/lib/arel_extensions/visitors/ibm_db.rb +12 -5
  71. data/lib/arel_extensions/visitors/mssql.rb +58 -64
  72. data/lib/arel_extensions/visitors/mysql.rb +98 -149
  73. data/lib/arel_extensions/visitors/oracle.rb +70 -73
  74. data/lib/arel_extensions/visitors/oracle12.rb +15 -2
  75. data/lib/arel_extensions/visitors/postgresql.rb +63 -116
  76. data/lib/arel_extensions/visitors/sqlite.rb +70 -83
  77. data/lib/arel_extensions/visitors/to_sql.rb +110 -142
  78. data/lib/arel_extensions/visitors.rb +60 -68
  79. data/lib/arel_extensions.rb +19 -81
  80. data/test/database.yml +0 -2
  81. data/test/helper.rb +18 -0
  82. data/test/real_db_test.rb +43 -28
  83. data/test/support/fake_record.rb +2 -2
  84. data/test/test_comparators.rb +12 -9
  85. data/test/visitors/test_bulk_insert_oracle.rb +8 -8
  86. data/test/visitors/test_bulk_insert_sqlite.rb +10 -9
  87. data/test/visitors/test_bulk_insert_to_sql.rb +10 -8
  88. data/test/visitors/test_oracle.rb +42 -42
  89. data/test/visitors/test_to_sql.rb +196 -361
  90. data/test/with_ar/all_agnostic_test.rb +160 -195
  91. data/test/with_ar/insert_agnostic_test.rb +4 -3
  92. data/test/with_ar/test_bulk_sqlite.rb +9 -6
  93. data/test/with_ar/test_math_sqlite.rb +12 -8
  94. data/test/with_ar/test_string_mysql.rb +11 -5
  95. data/test/with_ar/test_string_sqlite.rb +12 -4
  96. metadata +11 -22
  97. data/.github/workflows/ruby.yml +0 -102
  98. data/gemfiles/rails6.gemfile +0 -30
  99. data/gemfiles/rails6_1.gemfile +0 -30
  100. data/gemspecs/arel_extensions-v1.gemspec +0 -28
  101. data/gemspecs/arel_extensions-v2.gemspec +0 -28
  102. data/generate_gems.sh +0 -15
  103. data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
  104. data/lib/arel_extensions/nodes/sum.rb +0 -7
  105. data/lib/arel_extensions/visitors/convert_format.rb +0 -37
  106. data/test/arelx_test_helper.rb +0 -26
  107. data/version_v1.rb +0 -3
  108. data/version_v2.rb +0 -3
@@ -1,8 +1,9 @@
1
- require 'arelx_test_helper'
1
+ require 'helper'
2
2
  require 'date'
3
3
 
4
4
  module ArelExtensions
5
5
  module WthAr
6
+
6
7
  class InsertManagerTest < Minitest::Test
7
8
  def setup_db
8
9
  ActiveRecord::Base.configurations = YAML.load_file('test/database.yml')
@@ -22,7 +23,7 @@ module ArelExtensions
22
23
  @cnx.execute(sql) rescue $stderr << "can't create functions\n"
23
24
  end
24
25
  end
25
- @cnx.drop_table(:user_tests) rescue nil
26
+ @cnx.drop_table(:user_tests) rescue nil
26
27
  @cnx.create_table :user_tests do |t|
27
28
  t.column :age, :integer
28
29
  t.column :name, :string
@@ -76,8 +77,8 @@ END;])
76
77
  insert_manager.bulk_insert(@cols2, @data2)
77
78
  @cnx.execute(insert_manager.to_sql)
78
79
  assert_equal 4, User.count, "insertions failed"
79
-
80
80
  end
81
+
81
82
  end
82
83
  end
83
84
  end
@@ -1,8 +1,10 @@
1
- require 'arelx_test_helper'
1
+ require 'helper'
2
2
 
3
3
  module ArelExtensions
4
4
  module WthAr
5
+
5
6
  describe 'the sqlite visitor' do
7
+
6
8
  before do
7
9
  ActiveRecord::Base.configurations = YAML.load_file('test/database.yml')
8
10
  ActiveRecord::Base.establish_connection(ENV['DB'] || (RUBY_PLATFORM == 'java' ? :"jdbc-sqlite" : :sqlite))
@@ -10,7 +12,7 @@ module ArelExtensions
10
12
  @cnx = ActiveRecord::Base.connection
11
13
  Arel::Table.engine = ActiveRecord::Base
12
14
  @cnx.drop_table(:users) rescue nil
13
- @cnx.drop_table(:products) rescue nil
15
+ @cnx.drop_table(:products) rescue nil
14
16
  @cnx.create_table :users do |t|
15
17
  t.column :age, :integer
16
18
  t.column :name, :string
@@ -36,10 +38,11 @@ module ArelExtensions
36
38
  it "should import large set of data" do
37
39
  insert_manager = Arel::VERSION.to_i > 6 ? Arel::InsertManager.new().into(@table) : Arel::InsertManager.new(ActiveRecord::Base).into(@table)
38
40
  insert_manager.bulk_insert(@cols, @data)
39
- _(insert_manager.to_sql)
40
- .must_be_like %Q[INSERT INTO "users" ("id", "name", "comments", "created_at")
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']
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']
42
43
  end
44
+
43
45
  end
46
+
44
47
  end
45
- end
48
+ end
@@ -1,16 +1,18 @@
1
- require 'arelx_test_helper'
1
+ require 'helper'
2
2
 
3
3
  module ArelExtensions
4
4
  module WthAr
5
+
5
6
  describe 'the sqlite visitor can do maths' do
7
+
6
8
  before do
7
9
  ActiveRecord::Base.configurations = YAML.load_file('test/database.yml')
8
10
  ActiveRecord::Base.establish_connection(ENV['DB'] || (RUBY_PLATFORM == 'java' ? :"jdbc-sqlite" : :sqlite))
9
11
  ActiveRecord::Base.default_timezone = :utc
10
12
  Arel::Table.engine = ActiveRecord::Base
11
13
  @cnx = ActiveRecord::Base.connection
12
- @cnx.drop_table(:users) rescue nil
13
- @cnx.drop_table(:products) rescue nil
14
+ @cnx.drop_table(:users) rescue nil
15
+ @cnx.drop_table(:products) rescue nil
14
16
  @cnx.create_table :users do |t|
15
17
  t.column :age, :integer
16
18
  t.column :name, :string
@@ -42,19 +44,21 @@ module ArelExtensions
42
44
  end
43
45
 
44
46
  it "should do maths" do
45
- # ABS
47
+ #ABS
46
48
  assert_equal 20, User.where(:id => @neg.id).select(@age.abs.as("res")).first.res
47
49
  assert_equal 14, User.where(:id => @laure.id).select((@age - 39).abs.as("res")).first.res
48
50
 
49
- # CEIL # require extensions
51
+ #CEIL # require extensions
50
52
 
51
53
  # RAND
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
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
54
56
  assert 42 != User.select(Arel.rand.as('res')).first.res
55
57
  assert 0 <= User.select(Arel.rand.abs.as('res')).first.res
56
58
  assert_equal 8, User.order(Arel.rand).limit(50).count
57
59
  end
60
+
58
61
  end
62
+
59
63
  end
60
- end
64
+ end
@@ -1,14 +1,16 @@
1
- require 'arelx_test_helper'
1
+ require 'helper'
2
2
  require 'date'
3
3
 
4
4
  module ArelExtensions
5
5
  module WthAr
6
+
6
7
  describe 'the mysql visitor can do string operations' do
8
+
7
9
  before do
8
10
  ActiveRecord::Base.configurations = YAML.load_file('test/database.yml')
9
11
  ActiveRecord::Base.establish_connection(ENV['DB'] || (RUBY_PLATFORM == 'java' ? :"jdbc-mysql" : :mysql))
10
12
  ActiveRecord::Base.default_timezone = :utc
11
- begin
13
+ begin
12
14
  @cnx = ActiveRecord::Base.connection
13
15
  rescue => e
14
16
  puts "\n#{e.inspect}"
@@ -17,7 +19,7 @@ module ArelExtensions
17
19
  end
18
20
  Arel::Table.engine = ActiveRecord::Base
19
21
  @cnx.drop_table(:users) rescue nil
20
- @cnx.drop_table(:products) rescue nil
22
+ @cnx.drop_table(:products) rescue nil
21
23
  @cnx.create_table :users do |t|
22
24
  t.column :age, :integer
23
25
  t.column :name, :string
@@ -57,7 +59,7 @@ module ArelExtensions
57
59
  assert_equal "Sophie15", @sophie.select((User.arel_table[:name] + User.arel_table[:age]).as("res")).first.res
58
60
  assert_equal "SophieSophie", @sophie.select((User.arel_table[:name] + User.arel_table[:name]).as("res")).first.res
59
61
  assert_equal "Sophie2016-05-23", @sophie.select((User.arel_table[:name] + User.arel_table[:created_at]).as("res")).first.res
60
- # concat Integer
62
+ #concat Integer
61
63
  assert_equal 1, User.where((User.arel_table[:age] + 10).eq(33)).count
62
64
  assert_equal 1, User.where((User.arel_table[:age] + "1").eq(6)).count
63
65
  assert_equal 1, User.where((User.arel_table[:age] + User.arel_table[:age]).eq(10)).count
@@ -65,7 +67,11 @@ module ArelExtensions
65
67
  # Replace
66
68
  assert_equal "LucaX", User.where(:id => @lucas).select(@name.replace("s","X").as("res")).first.res
67
69
  assert_equal "replace", User.where(:id => @lucas).select(@name.replace(@name,"replace").as("res")).first.res
70
+
71
+ #
68
72
  end
73
+
69
74
  end
75
+
70
76
  end
71
- end
77
+ end
@@ -1,16 +1,18 @@
1
- require 'arelx_test_helper'
1
+ require 'helper'
2
2
  require 'date'
3
3
 
4
4
  module ArelExtensions
5
5
  module WthAr
6
+
6
7
  describe 'the sqlite visitor can do string operations' do
8
+
7
9
  before do
8
10
  ActiveRecord::Base.configurations = YAML.load_file('test/database.yml')
9
11
  ActiveRecord::Base.establish_connection(ENV['DB'] || (RUBY_PLATFORM == 'java' ? :"jdbc-sqlite" : :sqlite))
10
12
  ActiveRecord::Base.default_timezone = :utc
11
13
  @cnx = ActiveRecord::Base.connection
12
14
  Arel::Table.engine = ActiveRecord::Base
13
- @cnx.drop_table(:users) rescue nil
15
+ @cnx.drop_table(:users) rescue nil
14
16
  @cnx.create_table :users do |t|
15
17
  t.column :age, :integer
16
18
  t.column :name, :string
@@ -50,15 +52,21 @@ module ArelExtensions
50
52
  assert_equal "Sophie15", @sophie.select((User.arel_table[:name] + User.arel_table[:age]).as("res")).first.res
51
53
  assert_equal "SophieSophie", @sophie.select((User.arel_table[:name] + User.arel_table[:name]).as("res")).first.res
52
54
  assert_equal "Sophie2016-05-23", @sophie.select((User.arel_table[:name] + User.arel_table[:created_at]).as("res")).first.res
53
- # concat Integer
55
+ #concat Integer
54
56
  assert_equal 1, User.where((User.arel_table[:age] + 10).eq(33)).count
55
57
  assert_equal 1, User.where((User.arel_table[:age] + "1").eq(6)).count
56
58
  assert_equal 1, User.where((User.arel_table[:age] + User.arel_table[:age]).eq(10)).count
57
59
 
60
+
61
+
58
62
  # Replace
59
63
  assert_equal "LucaX", User.where(:id => @lucas).select(@name.replace("s","X").as("res")).first.res
60
64
  assert_equal "replace", User.where(:id => @lucas).select(@name.replace(@name,"replace").as("res")).first.res
65
+
66
+ #
61
67
  end
68
+
62
69
  end
70
+
63
71
  end
64
- end
72
+ 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.25
4
+ version: 2.0.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yann Azoury
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-04-21 00:00:00.000000000 Z
13
+ date: 2019-08-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: arel
16
+ name: activerecord
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '6.0'
21
+ version: 6.0.0.rc2
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '6.0'
28
+ version: 6.0.0.rc2
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: minitest
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: 12.3.3
63
+ version: '11'
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: 12.3.3
70
+ version: '11'
71
71
  description: Adds new features to Arel
72
72
  email:
73
73
  - yann.azoury@faveod.com
@@ -81,7 +81,6 @@ extra_rdoc_files:
81
81
  - functions.html
82
82
  files:
83
83
  - ".codeclimate.yml"
84
- - ".github/workflows/ruby.yml"
85
84
  - ".gitignore"
86
85
  - ".rubocop.yml"
87
86
  - ".travis.yml"
@@ -105,11 +104,6 @@ files:
105
104
  - gemfiles/rails5_0.gemfile
106
105
  - gemfiles/rails5_1_4.gemfile
107
106
  - gemfiles/rails5_2.gemfile
108
- - gemfiles/rails6.gemfile
109
- - gemfiles/rails6_1.gemfile
110
- - gemspecs/arel_extensions-v1.gemspec
111
- - gemspecs/arel_extensions-v2.gemspec
112
- - generate_gems.sh
113
107
  - init/mssql.sql
114
108
  - init/mysql.sql
115
109
  - init/oracle.sql
@@ -126,7 +120,6 @@ files:
126
120
  - lib/arel_extensions/math_functions.rb
127
121
  - lib/arel_extensions/nodes.rb
128
122
  - lib/arel_extensions/nodes/abs.rb
129
- - lib/arel_extensions/nodes/aggregate_function.rb
130
123
  - lib/arel_extensions/nodes/blank.rb
131
124
  - lib/arel_extensions/nodes/case.rb
132
125
  - lib/arel_extensions/nodes/cast.rb
@@ -158,7 +151,6 @@ files:
158
151
  - lib/arel_extensions/nodes/soundex.rb
159
152
  - lib/arel_extensions/nodes/std.rb
160
153
  - lib/arel_extensions/nodes/substring.rb
161
- - lib/arel_extensions/nodes/sum.rb
162
154
  - lib/arel_extensions/nodes/then.rb
163
155
  - lib/arel_extensions/nodes/trim.rb
164
156
  - lib/arel_extensions/nodes/union.rb
@@ -172,7 +164,6 @@ files:
172
164
  - lib/arel_extensions/tasks.rb
173
165
  - lib/arel_extensions/version.rb
174
166
  - lib/arel_extensions/visitors.rb
175
- - lib/arel_extensions/visitors/convert_format.rb
176
167
  - lib/arel_extensions/visitors/ibm_db.rb
177
168
  - lib/arel_extensions/visitors/mssql.rb
178
169
  - lib/arel_extensions/visitors/mysql.rb
@@ -181,8 +172,8 @@ files:
181
172
  - lib/arel_extensions/visitors/postgresql.rb
182
173
  - lib/arel_extensions/visitors/sqlite.rb
183
174
  - lib/arel_extensions/visitors/to_sql.rb
184
- - test/arelx_test_helper.rb
185
175
  - test/database.yml
176
+ - test/helper.rb
186
177
  - test/real_db_test.rb
187
178
  - test/support/alter_system_user_password.sql
188
179
  - test/support/create_oracle_enhanced_users.sql
@@ -199,8 +190,6 @@ files:
199
190
  - test/with_ar/test_math_sqlite.rb
200
191
  - test/with_ar/test_string_mysql.rb
201
192
  - test/with_ar/test_string_sqlite.rb
202
- - version_v1.rb
203
- - version_v2.rb
204
193
  homepage: https://github.com/Faveod/arel-extensions
205
194
  licenses:
206
195
  - MIT
@@ -218,11 +207,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
207
  version: '0'
219
208
  required_rubygems_version: !ruby/object:Gem::Requirement
220
209
  requirements:
221
- - - ">="
210
+ - - ">"
222
211
  - !ruby/object:Gem::Version
223
- version: '0'
212
+ version: 1.3.1
224
213
  requirements: []
225
- rubygems_version: 3.1.2
214
+ rubygems_version: 3.0.2
226
215
  signing_key:
227
216
  specification_version: 4
228
217
  summary: Extending Arel
@@ -1,102 +0,0 @@
1
- # This workflow uses actions that are not certified by GitHub.
2
- # They are provided by a third-party and are governed by
3
- # separate terms of service, privacy policy, and support
4
- # documentation.
5
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
-
8
- name: Ruby
9
-
10
- on:
11
- push:
12
- branches: [ master ]
13
- pull_request:
14
- branches: [ master ]
15
-
16
- jobs:
17
- test:
18
-
19
- runs-on: ubuntu-latest
20
-
21
- services:
22
- postgres:
23
- image: postgres:11.6-alpine
24
- env:
25
- POSTGRES_DB: arext_test
26
- ports:
27
- - 5432:5432
28
- # needed because the postgres container does not provide a healthcheck
29
- options: >-
30
- --health-cmd "pg_isready -d arext_test -U postgres -p 5432"
31
- --health-interval 10s
32
- --health-timeout 5s
33
- --health-retries 5
34
- mysql:
35
- image: mysql:5.7
36
- env:
37
- MYSQL_ALLOW_EMPTY_PASSWORD: true
38
- MYSQL_USERNAME: travis
39
- MYSQL_DATABASE: arext_test
40
- ports:
41
- - 3306:3306
42
- options: >-
43
- --health-cmd="mysqladmin ping"
44
- --health-interval=10s
45
- --health-timeout=5s
46
- --health-retries=3
47
-
48
- strategy:
49
- matrix:
50
- ruby-version:
51
- - 3.0.0-preview1
52
- - 2.7
53
- - 2.5
54
- - 2.3
55
- rails-version:
56
- - 6_1
57
- - 6
58
- - 5_2
59
- exclude:
60
- - ruby-version: 2.3
61
- rails-version: 6_1
62
- - ruby-version: 2.3
63
- rails-version: 6
64
- - ruby-version: 3.0.0-preview1
65
- rails-version: 5.2
66
- continue-on-error: ${{ true }}
67
-
68
- steps:
69
- - uses: actions/checkout@v2
70
- - name: Set up Ruby
71
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
72
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
73
- # uses: ruby/setup-ruby@v1
74
- uses: ruby/setup-ruby@21351ecc0a7c196081abca5dc55b08f085efe09a
75
- with:
76
- ruby-version: ${{ matrix.ruby-version }}
77
- - name: Setup gemspec
78
- if: ${{ matrix.rails-version == '6_1' || matrix.rails-version == '6' }}
79
- run: cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
80
- - name: Install dependencies
81
- run: |
82
- export BUNDLE_GEMFILE=gemfiles/rails${{ matrix.rails-version }}.gemfile
83
- bundle install
84
- - name: Run test to_sql
85
- run: rake test:to_sql
86
- - name: Run test Postgres
87
- env:
88
- PGHOST: localhost
89
- PGUSER: postgres
90
- run: rake test:postgresql
91
- - name: Run test MySql
92
- env:
93
- DB_CONNECTION: mysql
94
- DB_HOST: 127.0.0.1
95
- DB_PORT: 3306
96
- DB_DATABASE: arext_test
97
- DB_USERNAME: travis
98
- run: |
99
- sudo apt-get install -y mysql-client
100
- mysql --host 127.0.0.1 --port 3306 -uroot -e 'create user travis;'
101
- mysql --host 127.0.0.1 --port 3306 -uroot -e 'GRANT ALL PRIVILEGES ON arext_test.* TO travis;'
102
- rake test:mysql
@@ -1,30 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'rails', '~> 6.0.0'
4
-
5
-
6
- group :development, :test do
7
- gem 'activesupport', '~> 6.0.0'
8
- gem 'activemodel', '~> 6.0.0'
9
- gem 'activerecord', '~> 6.0.0'
10
-
11
- gem "sqlite3", '~> 1.4', platforms: [:mri, :mswin, :mingw]
12
- gem "mysql2", '0.5.2', platforms: [:mri, :mswin, :mingw]
13
- gem "pg",'< 1.0.0', platforms: [:mri, :mingw]
14
-
15
- #gem "tiny_tds", platforms: [:mri, :mingw] if RUBY_PLATFORM =~ /windows/
16
- #gem "activerecord-sqlserver-adapter", platforms: [:mri, :mingw]
17
-
18
- gem 'ruby-oci8', platforms: [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
19
- gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0' if ENV.has_key? 'ORACLE_HOME'
20
-
21
- # for JRuby
22
- gem 'activerecord-jdbc-adapter', platforms: :jruby
23
- gem "jdbc-sqlite3", platforms: :jruby
24
- gem "activerecord-jdbcsqlite3-adapter", platforms: :jruby
25
- gem "activerecord-jdbcmysql-adapter", platforms: :jruby
26
- gem "activerecord-jdbcpostgresql-adapter", platforms: :jruby
27
- gem "activerecord-jdbcmssql-adapter", platforms: :jruby
28
- end
29
-
30
- gemspec path: "../"
@@ -1,30 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'rails', '~> 6.1.0'
4
-
5
-
6
- group :development, :test do
7
- gem 'activesupport', '~> 6.1.0'
8
- gem 'activemodel', '~> 6.1.0'
9
- gem 'activerecord', '~> 6.1.0'
10
-
11
- gem "sqlite3", '~> 1.4', platforms: [:mri, :mswin, :mingw]
12
- gem "mysql2", '0.5.2', platforms: [:mri, :mswin, :mingw]
13
- gem "pg",'~> 1.1', platforms: [:mri, :mingw]
14
-
15
- #gem "tiny_tds", platforms: [:mri, :mingw] if RUBY_PLATFORM =~ /windows/
16
- #gem "activerecord-sqlserver-adapter", platforms: [:mri, :mingw]
17
-
18
- gem 'ruby-oci8', platforms: [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
19
- gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0' if ENV.has_key? 'ORACLE_HOME'
20
-
21
- # for JRuby
22
- gem 'activerecord-jdbc-adapter', platforms: :jruby
23
- gem "jdbc-sqlite3", platforms: :jruby
24
- gem "activerecord-jdbcsqlite3-adapter", platforms: :jruby
25
- gem "activerecord-jdbcmysql-adapter", platforms: :jruby
26
- gem "activerecord-jdbcpostgresql-adapter", platforms: :jruby
27
- gem "activerecord-jdbcmssql-adapter", platforms: :jruby
28
- end
29
-
30
- gemspec path: "../"
@@ -1,28 +0,0 @@
1
- $:.push File.expand_path("../lib", __FILE__)
2
- require "arel_extensions/version"
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "arel_extensions"
6
- s.version = ArelExtensions::VERSION
7
- s.platform = Gem::Platform::RUBY
8
- s.authors = ["Yann Azoury", "Félix Bellanger", "Julien Delporte"]
9
- s.email = ["yann.azoury@faveod.com", "felix.bellanger@faveod.com", "julien.delporte@faveod.com"]
10
- s.homepage = "https://github.com/Faveod/arel-extensions"
11
- s.description = "Adds new features to Arel"
12
- s.summary = "Extending Arel"
13
- s.license = 'MIT'
14
-
15
- s.rdoc_options = ["--main", "README.md"]
16
- s.extra_rdoc_files = ["MIT-LICENSE.txt", "README.md", 'functions.html']
17
-
18
- # Manifest
19
- s.files = `git ls-files`.split("\n")
20
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
- s.require_paths = ["lib"]
22
-
23
- s.add_dependency('arel', '>= 6.0')
24
-
25
- s.add_development_dependency('minitest', '~> 5.9')
26
- s.add_development_dependency('rdoc', '~> 4.0')
27
- s.add_development_dependency('rake', '~> 12.3.3')
28
- end
@@ -1,28 +0,0 @@
1
- $:.push File.expand_path("../lib", __FILE__)
2
- require "arel_extensions/version"
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "arel_extensions"
6
- s.version = ArelExtensions::VERSION
7
- s.platform = Gem::Platform::RUBY
8
- s.authors = ["Yann Azoury", "Félix Bellanger", "Julien Delporte"]
9
- s.email = ["yann.azoury@faveod.com", "felix.bellanger@faveod.com", "julien.delporte@faveod.com"]
10
- s.homepage = "https://github.com/Faveod/arel-extensions"
11
- s.description = "Adds new features to Arel"
12
- s.summary = "Extending Arel"
13
- s.license = 'MIT'
14
-
15
- s.rdoc_options = ["--main", "README.md"]
16
- s.extra_rdoc_files = ["MIT-LICENSE.txt", "README.md", 'functions.html']
17
-
18
- # Manifest
19
- s.files = `git ls-files`.split("\n")
20
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
- s.require_paths = ["lib"]
22
-
23
- s.add_dependency('activerecord', '>= 6.0')
24
-
25
- s.add_development_dependency('minitest', '~> 5.9')
26
- s.add_development_dependency('rdoc', '~> 4.0')
27
- s.add_development_dependency('rake', '~> 12.3.3')
28
- end
data/generate_gems.sh DELETED
@@ -1,15 +0,0 @@
1
-
2
- #gem uninstall arel_extensions
3
-
4
- # VERSION ~> 1
5
- cp ./version_v1.rb lib/arel_extensions/version.rb
6
- cp ./gemspecs/arel_extensions-v1.gemspec ./arel_extensions.gemspec
7
- gem build ./arel_extensions.gemspec
8
-
9
- # VERSION ~> 2
10
- cp ./version_v2.rb lib/arel_extensions/version.rb
11
- mv ./arel_extensions.gemspec ./arel_extensions.gemspec.bck
12
- cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
13
- gem build ./arel_extensions.gemspec
14
- cp ./version_v1.rb lib/arel_extensions/version.rb
15
- cp ./gemspecs/arel_extensions-v1.gemspec ./arel_extensions.gemspec
@@ -1,13 +0,0 @@
1
- module ArelExtensions
2
- module Nodes
3
- class AggregateFunction < Function
4
- attr_accessor :order, :group
5
-
6
- def initialize node, **opts
7
- @order = Array(opts[:order]).map{|e| convert_to_node(e)}
8
- @group = Array(opts[:group]).map{|e| convert_to_node(e)}
9
- super [node]
10
- end
11
- end
12
- end
13
- end
@@ -1,7 +0,0 @@
1
- module ArelExtensions
2
- module Nodes
3
- class Sum < AggregateFunction
4
- RETURN_TYPE = :number
5
- end
6
- end
7
- end
@@ -1,37 +0,0 @@
1
- module ArelExtensions
2
- module Visitors
3
- # Convert date format in strftime syntax to whatever the RDBMs
4
- # wants, based on the table of conversion +mapping+.
5
- def self.strftime_to_format format, mapping
6
- @mapping_regexps ||= {}
7
- @mapping_regexps[mapping] ||=
8
- Regexp.new(
9
- mapping
10
- .keys
11
- .map{|k| Regexp.escape(k)}
12
- .join('|')
13
- )
14
-
15
- regexp = @mapping_regexps[mapping]
16
- s = StringScanner.new format
17
- res = StringIO.new
18
- while !s.eos?
19
- res <<
20
- case
21
- when s.scan(regexp)
22
- if v = mapping[s.matched]
23
- v
24
- else
25
- # Should never happen.
26
- s.matched
27
- end
28
- when s.scan(/[^%]+/)
29
- s.matched
30
- when s.scan(/./)
31
- s.matched
32
- end
33
- end
34
- res.string
35
- end
36
- end
37
- end
@@ -1,26 +0,0 @@
1
- require 'rubygems'
2
- require 'minitest/autorun'
3
- require 'fileutils'
4
- require 'arel'
5
- require 'active_record'
6
-
7
- require 'support/fake_record'
8
-
9
- require 'arel_extensions'
10
- Arel::Table.engine = FakeRecord::Base.new
11
-
12
- $arel_silence_type_casting_deprecation = true
13
-
14
- module Minitest::Assertions
15
- #
16
- # Fails unless +expected and +actual are the same string, modulo extraneous spaces.
17
- #
18
- def assert_like(expected, actual, msg = nil)
19
- msg ||= "Expected #{expected.inspect} and #{actual.inspect} to be alike"
20
- assert_equal expected.gsub(/\s+/, ' ').strip, actual.gsub(/\s+/, ' ').strip
21
- end
22
- end
23
-
24
- module Minitest::Expectations
25
- infect_an_assertion :assert_like, :must_be_like
26
- end
data/version_v1.rb DELETED
@@ -1,3 +0,0 @@
1
- module ArelExtensions
2
- VERSION = "1.2.25".freeze
3
- end
data/version_v2.rb DELETED
@@ -1,3 +0,0 @@
1
- module ArelExtensions
2
- VERSION = "2.0.22".freeze
3
- end