arel_extensions 2.0.4 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +54 -86
  3. data/README.md +1 -1
  4. data/Rakefile +13 -2
  5. data/arel_extensions.gemspec +1 -1
  6. data/gemfiles/rails4.gemfile +1 -1
  7. data/gemfiles/rails6.gemfile +1 -1
  8. data/generate_gems.sh +4 -3
  9. data/lib/arel_extensions.rb +33 -19
  10. data/lib/arel_extensions/attributes.rb +0 -1
  11. data/lib/arel_extensions/boolean_functions.rb +39 -12
  12. data/lib/arel_extensions/insert_manager.rb +7 -5
  13. data/lib/arel_extensions/nodes/abs.rb +0 -0
  14. data/lib/arel_extensions/nodes/case.rb +1 -1
  15. data/lib/arel_extensions/nodes/ceil.rb +0 -0
  16. data/lib/arel_extensions/nodes/coalesce.rb +0 -0
  17. data/lib/arel_extensions/nodes/concat.rb +0 -0
  18. data/lib/arel_extensions/nodes/duration.rb +0 -0
  19. data/lib/arel_extensions/nodes/find_in_set.rb +0 -0
  20. data/lib/arel_extensions/nodes/floor.rb +0 -0
  21. data/lib/arel_extensions/nodes/function.rb +0 -0
  22. data/lib/arel_extensions/nodes/is_null.rb +0 -0
  23. data/lib/arel_extensions/nodes/length.rb +0 -0
  24. data/lib/arel_extensions/nodes/locate.rb +0 -0
  25. data/lib/arel_extensions/nodes/rand.rb +0 -0
  26. data/lib/arel_extensions/nodes/replace.rb +0 -0
  27. data/lib/arel_extensions/nodes/round.rb +0 -0
  28. data/lib/arel_extensions/nodes/soundex.rb +0 -0
  29. data/lib/arel_extensions/nodes/substring.rb +0 -0
  30. data/lib/arel_extensions/nodes/trim.rb +0 -0
  31. data/lib/arel_extensions/nodes/union.rb +0 -0
  32. data/lib/arel_extensions/nodes/wday.rb +0 -0
  33. data/lib/arel_extensions/predications.rb +22 -19
  34. data/lib/arel_extensions/set_functions.rb +2 -2
  35. data/lib/arel_extensions/string_functions.rb +13 -0
  36. data/lib/arel_extensions/version.rb +1 -1
  37. data/lib/arel_extensions/visitors.rb +1 -1
  38. data/lib/arel_extensions/visitors/ibm_db.rb +1 -1
  39. data/lib/arel_extensions/visitors/mysql.rb +24 -9
  40. data/lib/arel_extensions/visitors/oracle.rb +7 -8
  41. data/lib/arel_extensions/visitors/postgresql.rb +1 -1
  42. data/lib/arel_extensions/visitors/sqlite.rb +11 -7
  43. data/lib/arel_extensions/visitors/to_sql.rb +31 -38
  44. data/test/arelx_test_helper.rb +28 -0
  45. data/test/support/fake_record.rb +4 -0
  46. data/test/test_comparators.rb +8 -7
  47. data/test/visitors/test_bulk_insert_oracle.rb +4 -3
  48. data/test/visitors/test_bulk_insert_sqlite.rb +4 -3
  49. data/test/visitors/test_bulk_insert_to_sql.rb +3 -3
  50. data/test/visitors/test_oracle.rb +41 -41
  51. data/test/visitors/test_to_sql.rb +359 -206
  52. data/test/with_ar/all_agnostic_test.rb +18 -8
  53. data/test/with_ar/insert_agnostic_test.rb +1 -1
  54. data/test/with_ar/test_bulk_sqlite.rb +4 -3
  55. data/test/with_ar/test_math_sqlite.rb +1 -1
  56. data/test/with_ar/test_string_mysql.rb +1 -1
  57. data/test/with_ar/test_string_sqlite.rb +1 -1
  58. data/version_v1.rb +1 -1
  59. data/version_v2.rb +1 -1
  60. metadata +3 -3
  61. data/test/helper.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 808040009223c9a359d5e61e55f84a51dad939ee8b388ec04e52cfd6554f0ef9
4
- data.tar.gz: 836a734a724fd5328a66483d8d433a93eef9cbbaf78cf5e4ea10877c283c9ddc
3
+ metadata.gz: 5080e8422006270a6c69337931908b043c1c494679d453a8ea89328390e84174
4
+ data.tar.gz: 9189ce88f62c39a385dc5b5fa55a021d8c7c2967d7025eb4710d1403ac9dc078
5
5
  SHA512:
6
- metadata.gz: eb328d50ea6213bf785f0a03ebb1b23494fb66e8c60bf7a8873ffc84f3d78e5f9d2ec57367b7a5475872a899134edf5332e2b8dfe90128d22a7fe650e95c4f95
7
- data.tar.gz: e9098b71c1fdb119c5a3e6a18409ce3096487eb8a5adffc827dde03fbf65139d37fe1bef525c4b261a1ddfbfb3cfa4f0ca079152519c6f3c5813975b5a9b3c5b
6
+ metadata.gz: f477cee1a8ce18be9346c1b10fc10b90e0cf28921f2dc518a67e49aba8dba771b73a0c2d822b2fd6336b4596c0684526f044b0d02d0b4c77792c765174d7d350
7
+ data.tar.gz: 45da36b498e8c905e2d6793234fa2a094947e450a9a58e52d272ade8d63f474008d2bfc2ec674305224bc8650a9e55d3446211fb5f0258ad7a2bcada2a38e991
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  sudo: required
3
+ dist: trusty
3
4
  cache:
4
5
  bundler: true
5
6
  directories:
@@ -15,21 +16,23 @@ before_install:
15
16
  # - sh -ex .travis/oracle/install.sh
16
17
  # - .travis/setup_accounts.sh
17
18
  install:
18
- - gem install bundler -v 1.17.3
19
19
  - bundle install
20
20
  gemfile:
21
21
  - gemfiles/rails4.gemfile
22
22
  - gemfiles/rails5_0.gemfile
23
23
  - gemfiles/rails5_1_4.gemfile
24
24
  - gemfiles/rails5_2.gemfile
25
+ - gemfiles/rails6.gemfile
25
26
  services:
26
27
  - mysql
27
28
  - postgresql
29
+ addons:
30
+ postgresql: '9.4'
28
31
  before_script:
29
32
  - mysql -e 'create database arext_test;'
30
33
  - psql -c 'create database arext_test;' -U postgres
31
34
  script:
32
- - gem build arel_extensions.gemspec
35
+ - ./generate_gems.sh
33
36
  - bundle exec rake test
34
37
  - bundle exec rake test:sqlite
35
38
  - bundle exec rake test:mysql
@@ -55,72 +58,33 @@ rvm:
55
58
  - 2.3.1
56
59
  - 2.4.0
57
60
  - 2.5.0
58
- - rbx-2
61
+ - 2.7.1
59
62
  - jruby-9.0.5.0
60
- - jruby-9.2.0.0
63
+ - jruby-9.2.11.1
61
64
  - jruby-head
62
- - ruby-head
63
65
  jdk:
64
- - openjdk7
65
66
  - oraclejdk8
66
67
  - oraclejdk9
67
68
  - openjdk10
68
- - oraclejdk10
69
69
  - openjdk11
70
70
  - oraclejdk11
71
71
  matrix:
72
72
  fast_finish: true
73
73
  exclude:
74
- - rvm: rbx-2
75
- jdk: openjdk7
76
74
  - rvm: 2.0.0
77
- jdk: openjdk7
78
- - rvm: 2.1
79
- jdk: openjdk7
80
- - rvm: 2.2.5
81
- jdk: openjdk7
82
- - rvm: 2.3.1
83
- jdk: openjdk7
84
- - rvm: 2.4.0
85
- jdk: openjdk7
86
- - rvm: 2.5.0
87
- jdk: openjdk7
88
- - rvm: ruby-head
89
- jdk: openjdk7
90
- - rvm: rbx-2
91
- jdk: oraclejdk8
92
- - rvm: 2.0.0
93
- jdk: oraclejdk8
94
- - rvm: 2.1
95
- jdk: oraclejdk8
96
- - rvm: 2.2.5
97
- jdk: oraclejdk8
98
- - rvm: 2.3.1
99
- jdk: oraclejdk8
100
- - rvm: 2.4.0
101
- jdk: oraclejdk8
102
- - rvm: 2.5.0
103
- jdk: oraclejdk8
104
- - rvm: ruby-head
105
- jdk: oraclejdk8
106
- - rvm: rbx-2
107
- jdk: oraclejdk10
108
- - rvm: 2.0.0
109
- jdk: oraclejdk10
75
+ jdk: oraclejdk9
110
76
  - rvm: 2.1
111
- jdk: oraclejdk10
77
+ jdk: oraclejdk9
112
78
  - rvm: 2.2.5
113
- jdk: oraclejdk10
79
+ jdk: oraclejdk9
114
80
  - rvm: 2.3.1
115
- jdk: oraclejdk10
81
+ jdk: oraclejdk9
116
82
  - rvm: 2.4.0
117
- jdk: oraclejdk10
83
+ jdk: oraclejdk9
118
84
  - rvm: 2.5.0
119
- jdk: oraclejdk10
120
- - rvm: ruby-head
121
- jdk: oraclejdk10
122
- - rvm: rbx-2
123
- jdk: openjdk10
85
+ jdk: oraclejdk9
86
+ - rvm: 2.7.1
87
+ jdk: oraclejdk9
124
88
  - rvm: 2.0.0
125
89
  jdk: openjdk10
126
90
  - rvm: 2.1
@@ -133,10 +97,8 @@ matrix:
133
97
  jdk: openjdk10
134
98
  - rvm: 2.5.0
135
99
  jdk: openjdk10
136
- - rvm: ruby-head
100
+ - rvm: 2.7.1
137
101
  jdk: openjdk10
138
- - rvm: rbx-2
139
- jdk: oraclejdk11
140
102
  - rvm: 2.0.0
141
103
  jdk: oraclejdk11
142
104
  - rvm: 2.1
@@ -149,10 +111,8 @@ matrix:
149
111
  jdk: oraclejdk11
150
112
  - rvm: 2.5.0
151
113
  jdk: oraclejdk11
152
- - rvm: ruby-head
114
+ - rvm: 2.7.1
153
115
  jdk: oraclejdk11
154
- - rvm: rbx-2
155
- jdk: openjdk11
156
116
  - rvm: 2.0.0
157
117
  jdk: openjdk11
158
118
  - rvm: 2.1
@@ -165,59 +125,67 @@ matrix:
165
125
  jdk: openjdk11
166
126
  - rvm: 2.5.0
167
127
  jdk: openjdk11
168
- - rvm: ruby-head
128
+ - rvm: 2.7.1
169
129
  jdk: openjdk11
170
- - rvm: jruby-9.2.0.0
171
- jdk: openjdk7
172
- - rvm: jruby-head
173
- jdk: openjdk7
174
- - rvm: 2.0.0
175
- gemfile: gemfiles/rails5_1_4.gemfile
176
- - rvm: 2.1
177
- gemfile: gemfiles/rails5_1_4.gemfile
178
- - rvm: 2.2.5
179
- gemfile: gemfiles/rails5_1_4.gemfile
180
- - rvm: ruby-head
130
+ - rvm: 2.7.1
131
+ gemfile: gemfiles/rails4.gemfile
132
+ - rvm : jruby-9.2.11.1
181
133
  gemfile: gemfiles/rails4.gemfile
182
134
  - rvm: 2.0.0
183
135
  gemfile: gemfiles/rails5_0.gemfile
184
136
  - rvm: 2.1
185
137
  gemfile: gemfiles/rails5_0.gemfile
186
- - rvm: jruby-9.0.5.0
138
+ - rvm: 2.7.1
139
+ gemfile: gemfiles/rails5.0.gemfile
140
+ - rvm: 2.0.0
141
+ gemfile: gemfiles/rails5_1_4.gemfile
142
+ - rvm: 2.1
143
+ gemfile: gemfiles/rails5_1_4.gemfile
144
+ - rvm: 2.2.5
187
145
  gemfile: gemfiles/rails5_1_4.gemfile
146
+ - rvm: 2.7.1
147
+ gemfile: gemfiles/rails5.1.4.gemfile
148
+ - rvm: 2.7.1
149
+ gemfile: gemfiles/rails5.1.4.gemfile
188
150
  - rvm: 2.0.0
189
151
  gemfile: gemfiles/rails5_2.gemfile
190
152
  - rvm: 2.1
191
153
  gemfile: gemfiles/rails5_2.gemfile
192
- allow_failures:
193
- - rvm: rbx-2
194
- gemfile: gemfiles/rails4.gemfile
195
- - rvm: rbx-2
196
- gemfile: gemfiles/rails5_0.gemfile
197
- - rvm: rbx-2
198
- gemfile: gemfiles/rails5_1_4.gemfile
199
- - rvm: rbx-2
154
+ - rvm: 2.2.5
200
155
  gemfile: gemfiles/rails5_2.gemfile
201
- - rvm: rbx-2
156
+ - rvm: 2.7.1
157
+ gemfile: gemfiles/rails5.2.gemfile
158
+ - rvm: 2.0.0
159
+ gemfile: gemfiles/rails6.gemfile
160
+ - rvm: 2.1
161
+ gemfile: gemfiles/rails6.gemfile
162
+ - rvm: 2.2.5
163
+ gemfile: gemfiles/rails6.gemfile
164
+ - rvm: 2.3.1
165
+ gemfile: gemfiles/rails6.gemfile
166
+ - rvm: 2.4.0
167
+ gemfile: gemfiles/rails6.gemfile
168
+ allow_failures:
169
+ - rvm: jruby-9.0.5.0
202
170
  gemfile: gemfiles/rails5_1_4.gemfile
203
171
  - rvm: jruby-9.0.5.0
204
172
  gemfile: gemfiles/rails5_2.gemfile
205
- - rvm: jruby-9.2.0.0
173
+ - rvm: jruby-9.2.11.1
206
174
  jdk: oraclejdk9
207
175
  gemfile: gemfiles/rails5_2.gemfile
176
+ - jdk: oraclejdk9
208
177
  - jdk: openjdk10
209
- - jdk: oraclejdk10
210
178
  - jdk: openjdk11
211
179
  - jdk: oraclejdk11
212
- - rvm: ruby-head
213
180
  - rvm: jruby-head
214
- - rvm: jruby-9.2.0.0
181
+ - rvm: jruby-9.2.11.1
215
182
  jdk: oraclejdk9
216
183
  - rvm: jruby-9.0.5.0
217
184
  jdk: oraclejdk9
185
+ - rvm: 2.7.1
186
+ - gemfile: gemfiles/rails6.gemfile
218
187
  bundler_args: "--jobs 3 --retry 2"
219
188
  notifications:
220
189
  email:
221
- notifications:
222
- - julien.delporte@faveod.com
223
- - yann.azoury@faveod.com
190
+ - julien.delporte@faveod.com
191
+ - yann.azoury@faveod.com
data/README.md CHANGED
@@ -22,7 +22,7 @@ Arel 6 (Rails 4) or Arel 7+ (Rails 5).
22
22
  or
23
23
 
24
24
  Rails 6
25
- [Arel Repository](http://github.com/rails/rails)
25
+ [Rails Repository](http://github.com/rails/rails)
26
26
 
27
27
  ## Usage
28
28
 
data/Rakefile CHANGED
@@ -14,13 +14,24 @@ Rake::TestTask.new(:test) do |t|
14
14
  t.verbose = true
15
15
  end
16
16
 
17
- %w(mysql postgresql sqlite ibm_db oracle mssql).each do |adapter|
17
+ namespace :test do
18
+ Rake::TestTask.new('to_sql' => []) { |t|
19
+ t.libs << 'lib'
20
+ t.libs << 'test'
21
+ t.pattern = 'test/visitors/test_to_sql.rb'
22
+ t.warning = true
23
+ t.verbose = true
24
+ t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
25
+ }
26
+ end
27
+
28
+ %w[mysql postgresql sqlite ibm_db oracle mssql].each do |adapter|
18
29
  namespace :test do
19
30
  Rake::TestTask.new(adapter => "#{adapter}:env") { |t|
20
31
  t.libs << 'lib'
21
32
  t.libs << 'test'
22
33
  t.pattern = 'test/with_ar/*_agnostic_test.rb'
23
- t.warning = true
34
+ t.warning = false
24
35
  t.verbose = true
25
36
  t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
26
37
  }
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_dependency('arel', '>= 6.0')
23
+ s.add_dependency('activerecord', '>= 6.0')
24
24
 
25
25
  s.add_development_dependency('minitest', '~> 5.9')
26
26
  s.add_development_dependency('rdoc', '~> 4.0')
@@ -18,7 +18,7 @@ group :development, :test do
18
18
  gem 'activerecord-oracle_enhanced-adapter', '~> 1.6.0' if ENV.has_key? 'ORACLE_HOME'
19
19
 
20
20
  # for JRuby
21
- gem 'activerecord-jdbc-adapter', :platforms => :jruby
21
+ gem 'activerecord-jdbc-adapter', '~> 1.3' ,:platforms => :jruby
22
22
  gem "jdbc-sqlite3", :platforms => :jruby
23
23
  gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
24
24
  gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
@@ -27,4 +27,4 @@ group :development, :test do
27
27
  gem "activerecord-jdbcmssql-adapter", :platforms => :jruby
28
28
  end
29
29
 
30
- gemspec :path => "../"
30
+ gemspec :path => "../gemspec_v2/"
@@ -7,7 +7,8 @@ gem build ./arel_extensions.gemspec
7
7
 
8
8
  # VERSION ~> 2
9
9
  cp ./version_v2.rb lib/arel_extensions/version.rb
10
- cp ./gemspec_v2/arel_extensions-v2.gemspec ./tmp.gemspec
11
- gem build ./tmp.gemspec
10
+ mv ./arel_extensions.gemspec ./arel_extensions.gemspec.bck
11
+ cp ./gemspec_v2/arel_extensions-v2.gemspec ./arel_extensions.gemspec
12
+ gem build ./arel_extensions.gemspec
12
13
  cp ./version_v1.rb lib/arel_extensions/version.rb
13
- rm tmp.gemspec
14
+ cp ./arel_extensions.gemspec.bck ./arel_extensions.gemspec
@@ -7,35 +7,37 @@ require 'arel_extensions/railtie' if defined?(Rails::Railtie)
7
7
  # Count|NamedFunction < Function < Arel::Nodes::Node
8
8
 
9
9
  # pure Arel internals improvements
10
- Arel::Nodes::Binary.class_eval do
10
+ class Arel::Nodes::Binary
11
11
  include Arel::AliasPredication
12
12
  include Arel::Expressions
13
13
  end
14
14
 
15
- Arel::Nodes::Casted.class_eval do
15
+ class Arel::Nodes::Casted
16
16
  include Arel::AliasPredication
17
+
18
+ # They forget to define hash.
19
+ def hash
20
+ [self.class, self.val, self.attribute].hash
21
+ end
17
22
  end
18
23
 
19
- Arel::Nodes::Unary.class_eval do
24
+ class Arel::Nodes::Unary
20
25
  include Arel::Math
21
26
  include Arel::AliasPredication
22
27
  include Arel::Expressions
23
28
  end
24
29
 
25
- Arel::Nodes::Grouping.class_eval do
26
- include Arel::Math
27
- include Arel::AliasPredication
30
+ class Arel::Nodes::Grouping
28
31
  include Arel::OrderPredications
29
- include Arel::Expressions
30
32
  end
31
33
 
32
- Arel::Nodes::Function.class_eval do
34
+ class Arel::Nodes::Function
33
35
  include Arel::Math
34
36
  include Arel::Expressions
35
37
  end
36
38
 
37
39
  if Arel::VERSION >= "7.1.0"
38
- Arel::Nodes::Case.class_eval do
40
+ class Arel::Nodes::Case
39
41
  include Arel::Math
40
42
  include Arel::Expressions
41
43
  end
@@ -101,14 +103,18 @@ module Arel
101
103
  Arel::Nodes::Equality.new(1,0)
102
104
  end
103
105
 
106
+ def self.tuple *v
107
+ tmp = Arel::Nodes::Grouping.new(nil)
108
+ Arel::Nodes::Grouping.new(v.map{|e| tmp.convert_to_node(e)})
109
+ end
104
110
  end
105
111
 
106
- Arel::Attributes::Attribute.class_eval do
112
+ class Arel::Attributes::Attribute
107
113
  include Arel::Math
108
114
  include ArelExtensions::Attributes
109
115
  end
110
116
 
111
- Arel::Nodes::Function.class_eval do
117
+ class Arel::Nodes::Function
112
118
  include ArelExtensions::Math
113
119
  include ArelExtensions::Comparators
114
120
  include ArelExtensions::DateDuration
@@ -122,10 +128,19 @@ Arel::Nodes::Function.class_eval do
122
128
  def as other
123
129
  Arel::Nodes::As.new(self, Arel.sql(other))
124
130
  end
131
+ end
125
132
 
133
+ class Arel::Nodes::Grouping
134
+ include ArelExtensions::Math
135
+ include ArelExtensions::Comparators
136
+ include ArelExtensions::DateDuration
137
+ include ArelExtensions::MathFunctions
138
+ include ArelExtensions::NullFunctions
139
+ include ArelExtensions::StringFunctions
140
+ include ArelExtensions::Predications
126
141
  end
127
142
 
128
- Arel::Nodes::Unary.class_eval do
143
+ class Arel::Nodes::Unary
129
144
  include ArelExtensions::Math
130
145
  include ArelExtensions::Attributes
131
146
  include ArelExtensions::MathFunctions
@@ -133,7 +148,7 @@ Arel::Nodes::Unary.class_eval do
133
148
  include ArelExtensions::Predications
134
149
  end
135
150
 
136
- Arel::Nodes::Binary.class_eval do
151
+ class Arel::Nodes::Binary
137
152
  include ArelExtensions::Math
138
153
  include ArelExtensions::Attributes
139
154
  include ArelExtensions::MathFunctions
@@ -142,28 +157,27 @@ Arel::Nodes::Binary.class_eval do
142
157
  include ArelExtensions::Predications
143
158
  end
144
159
 
145
- Arel::Nodes::Equality.class_eval do
160
+ class Arel::Nodes::Equality
146
161
  include ArelExtensions::Comparators
147
162
  include ArelExtensions::DateDuration
148
163
  include ArelExtensions::MathFunctions
149
164
  include ArelExtensions::StringFunctions
150
165
  end
151
166
 
152
-
153
- Arel::InsertManager.class_eval do
167
+ class Arel::InsertManager
154
168
  include ArelExtensions::InsertManager
155
169
  end
156
170
 
157
- Arel::SelectManager.class_eval do
171
+ class Arel::SelectManager
158
172
  include ArelExtensions::SetFunctions
159
173
  include ArelExtensions::Nodes
160
174
  end
161
175
 
162
- Arel::Nodes::As.class_eval do
176
+ class Arel::Nodes::As
163
177
  include ArelExtensions::Nodes
164
178
  end
165
179
 
166
- Arel::Table.class_eval do
180
+ class Arel::Table
167
181
  alias_method :old_alias, :alias
168
182
  def alias(name = "#{self.name}_2")
169
183
  name.blank? ? self : Arel::Nodes::TableAlias.new(self,name)