arel_extensions 1.3.4 → 2.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +2 -1
  3. data/.rubocop.yml +4 -31
  4. data/.travis/oracle/download.js +152 -0
  5. data/.travis/oracle/download.sh +30 -0
  6. data/.travis/oracle/download_ojdbc.js +116 -0
  7. data/.travis/oracle/install.sh +34 -0
  8. data/.travis/setup_accounts.sh +9 -0
  9. data/.travis/sqlite3/extension-functions.sh +6 -0
  10. data/.travis.yml +223 -0
  11. data/Gemfile +21 -16
  12. data/README.md +14 -125
  13. data/Rakefile +30 -41
  14. data/TODO +1 -0
  15. data/appveyor.yml +44 -0
  16. data/arel_extensions.gemspec +14 -14
  17. data/functions.html +3 -3
  18. data/gemfiles/rails3.gemfile +10 -10
  19. data/gemfiles/rails4.gemfile +14 -14
  20. data/gemfiles/rails5_0.gemfile +14 -14
  21. data/gemfiles/rails5_1_4.gemfile +14 -14
  22. data/gemfiles/rails5_2.gemfile +14 -15
  23. data/init/mssql.sql +4 -4
  24. data/init/mysql.sql +38 -38
  25. data/init/oracle.sql +0 -0
  26. data/init/postgresql.sql +21 -21
  27. data/init/sqlite.sql +0 -0
  28. data/lib/arel_extensions/attributes.rb +3 -4
  29. data/lib/arel_extensions/boolean_functions.rb +14 -53
  30. data/lib/arel_extensions/common_sql_functions.rb +16 -15
  31. data/lib/arel_extensions/comparators.rb +28 -27
  32. data/lib/arel_extensions/date_duration.rb +14 -13
  33. data/lib/arel_extensions/insert_manager.rb +15 -18
  34. data/lib/arel_extensions/math.rb +44 -31
  35. data/lib/arel_extensions/math_functions.rb +39 -46
  36. data/lib/arel_extensions/nodes/abs.rb +1 -0
  37. data/lib/arel_extensions/nodes/blank.rb +2 -1
  38. data/lib/arel_extensions/nodes/case.rb +16 -16
  39. data/lib/arel_extensions/nodes/cast.rb +6 -8
  40. data/lib/arel_extensions/nodes/ceil.rb +1 -1
  41. data/lib/arel_extensions/nodes/coalesce.rb +3 -2
  42. data/lib/arel_extensions/nodes/collate.rb +10 -9
  43. data/lib/arel_extensions/nodes/concat.rb +18 -9
  44. data/lib/arel_extensions/nodes/date_diff.rb +22 -38
  45. data/lib/arel_extensions/nodes/duration.rb +3 -0
  46. data/lib/arel_extensions/nodes/find_in_set.rb +1 -0
  47. data/lib/arel_extensions/nodes/floor.rb +1 -1
  48. data/lib/arel_extensions/nodes/format.rb +8 -35
  49. data/lib/arel_extensions/nodes/formatted_number.rb +23 -22
  50. data/lib/arel_extensions/nodes/function.rb +37 -42
  51. data/lib/arel_extensions/nodes/is_null.rb +0 -0
  52. data/lib/arel_extensions/nodes/json.rb +39 -48
  53. data/lib/arel_extensions/nodes/length.rb +0 -5
  54. data/lib/arel_extensions/nodes/levenshtein_distance.rb +1 -1
  55. data/lib/arel_extensions/nodes/locate.rb +1 -0
  56. data/lib/arel_extensions/nodes/log10.rb +2 -1
  57. data/lib/arel_extensions/nodes/matches.rb +7 -5
  58. data/lib/arel_extensions/nodes/md5.rb +1 -0
  59. data/lib/arel_extensions/nodes/power.rb +5 -5
  60. data/lib/arel_extensions/nodes/rand.rb +1 -0
  61. data/lib/arel_extensions/nodes/repeat.rb +4 -2
  62. data/lib/arel_extensions/nodes/replace.rb +8 -16
  63. data/lib/arel_extensions/nodes/round.rb +6 -5
  64. data/lib/arel_extensions/nodes/soundex.rb +15 -15
  65. data/lib/arel_extensions/nodes/std.rb +21 -18
  66. data/lib/arel_extensions/nodes/substring.rb +16 -8
  67. data/lib/arel_extensions/nodes/trim.rb +5 -3
  68. data/lib/arel_extensions/nodes/union.rb +8 -5
  69. data/lib/arel_extensions/nodes/union_all.rb +7 -4
  70. data/lib/arel_extensions/nodes/wday.rb +4 -0
  71. data/lib/arel_extensions/nodes.rb +1 -1
  72. data/lib/arel_extensions/null_functions.rb +7 -5
  73. data/lib/arel_extensions/predications.rb +43 -44
  74. data/lib/arel_extensions/railtie.rb +5 -5
  75. data/lib/arel_extensions/set_functions.rb +7 -5
  76. data/lib/arel_extensions/string_functions.rb +29 -58
  77. data/lib/arel_extensions/tasks.rb +6 -6
  78. data/lib/arel_extensions/version.rb +1 -1
  79. data/lib/arel_extensions/visitors/ibm_db.rb +31 -24
  80. data/lib/arel_extensions/visitors/mssql.rb +184 -269
  81. data/lib/arel_extensions/visitors/mysql.rb +206 -271
  82. data/lib/arel_extensions/visitors/oracle.rb +175 -191
  83. data/lib/arel_extensions/visitors/oracle12.rb +31 -18
  84. data/lib/arel_extensions/visitors/postgresql.rb +170 -244
  85. data/lib/arel_extensions/visitors/sqlite.rb +124 -138
  86. data/lib/arel_extensions/visitors/to_sql.rb +237 -269
  87. data/lib/arel_extensions/visitors.rb +59 -75
  88. data/lib/arel_extensions.rb +31 -149
  89. data/test/database.yml +7 -15
  90. data/test/helper.rb +18 -0
  91. data/test/real_db_test.rb +113 -102
  92. data/test/support/fake_record.rb +3 -3
  93. data/test/test_comparators.rb +17 -14
  94. data/test/visitors/test_bulk_insert_oracle.rb +10 -10
  95. data/test/visitors/test_bulk_insert_sqlite.rb +12 -11
  96. data/test/visitors/test_bulk_insert_to_sql.rb +12 -10
  97. data/test/visitors/test_oracle.rb +55 -55
  98. data/test/visitors/test_to_sql.rb +226 -419
  99. data/test/with_ar/all_agnostic_test.rb +357 -567
  100. data/test/with_ar/insert_agnostic_test.rb +19 -25
  101. data/test/with_ar/test_bulk_sqlite.rb +15 -16
  102. data/test/with_ar/test_math_sqlite.rb +26 -26
  103. data/test/with_ar/test_string_mysql.rb +33 -31
  104. data/test/with_ar/test_string_sqlite.rb +34 -30
  105. metadata +23 -29
  106. data/.github/workflows/ruby.yml +0 -389
  107. data/gemfiles/rails6.gemfile +0 -29
  108. data/gemfiles/rails6_1.gemfile +0 -29
  109. data/gemfiles/rails7.gemfile +0 -22
  110. data/gemspecs/arel_extensions-v1.gemspec +0 -28
  111. data/gemspecs/arel_extensions-v2.gemspec +0 -28
  112. data/generate_gems.sh +0 -15
  113. data/lib/arel_extensions/aliases.rb +0 -14
  114. data/lib/arel_extensions/helpers.rb +0 -51
  115. data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
  116. data/lib/arel_extensions/nodes/sum.rb +0 -7
  117. data/lib/arel_extensions/visitors/convert_format.rb +0 -37
  118. data/test/arelx_test_helper.rb +0 -71
  119. data/version_v1.rb +0 -3
  120. data/version_v2.rb +0 -3
data/Gemfile CHANGED
@@ -1,24 +1,29 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rails', '~> 6.0.0.rc2'
2
4
 
3
- gemspec
4
5
 
5
6
  group :development, :test do
6
- gem 'sqlite3', '<= 1.3.13', platforms: [:mri]
7
- gem 'mysql2', '0.4.10', platforms: [:mri]
8
- gem 'pg', '< 1', platforms: [:mri]
7
+ gem 'activesupport', '~> 6.0.0.rc2'
8
+ gem 'activemodel', '~> 6.0.0.rc2'
9
+ gem 'activerecord', '~> 6.0.0.rc2'
9
10
 
10
- gem 'jdbc-sqlite3', platforms: :jruby
11
- gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
12
- gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
13
- gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
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
14
 
15
- gem 'tiny_tds', '~> 2.1', require: false, platforms: [:mri, :mingw, :x64_mingw, :mswin]
16
- gem 'activerecord-sqlserver-adapter', '~> 6.0', platforms: [:mri, :mingw, :x64_mingw, :mswin]
15
+ gem "tiny_tds", :platforms => [:mri, :mingw] if RUBY_PLATFORM =~ /windows/
16
+ gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw]
17
17
 
18
- gem 'ruby-oci8', platforms: [:mri, :mswin, :x64_mingw, :mingw]
19
- gem 'activerecord-oracle_enhanced-adapter', '~> 1.6.0'
18
+ gem 'ruby-oci8', :platforms => [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
19
+ gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0.rc2' if ENV.has_key? 'ORACLE_HOME'
20
20
 
21
- gem 'activesupport', '~> 6.0'
22
- gem 'activemodel', '~> 6.0'
23
- gem 'activerecord', '~> 6.0'
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
24
28
  end
29
+
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Arel Extensions
2
2
 
3
- ![GitHub workflow](https://github.com/Faveod/arel-extensions/actions/workflows/ruby.yml/badge.svg)
3
+ [![Travis Build Status](https://img.shields.io/travis/Faveod/arel-extensions.svg?label=Travis%20build)](http://travis-ci.org/Faveod/arel-extensions)
4
+ [![AppVeyor Build Status](https://img.shields.io/appveyor/ci/yazfav/arel-extensions.svg?label=AppVeyor%20build)](https://ci.appveyor.com/project/yazfav/arel-extensions)
4
5
  [![Security](https://hakiri.io/github/Faveod/arel-extensions/master.svg)](https://hakiri.io/github/Faveod/arel-extensions/master)
5
6
  ![](http://img.shields.io/badge/license-MIT-brightgreen.svg)
6
7
 
@@ -18,11 +19,6 @@ It allows to use more advanced SQL functions for any supported RDBMS.
18
19
  Arel 6 (Rails 4) or Arel 7+ (Rails 5).
19
20
  [Arel Repository](http://github.com/rails/arel)
20
21
 
21
- or
22
-
23
- Rails 6
24
- [Rails Repository](http://github.com/rails/rails)
25
-
26
22
  ## Usage
27
23
 
28
24
  Most of the features will work just by adding the gem to your Gemfiles. To make sure to get all the features for any dbms, you should execute the next line as soon as you get your connection to your DB:
@@ -76,9 +72,9 @@ With Arel Extensions:
76
72
  Other functions : ABS, RAND, ROUND, FLOOR, CEIL, FORMAT
77
73
 
78
74
  For Example:
79
- ```ruby
75
+ ```ruby
80
76
  t[:price].format_number("%07.2f €","fr_FR")
81
- # equivalent to 'sprintf("%07.2f €",price)' plus locale management
77
+ # equivalent to 'sprintf("%07.2f €",price)' plus locale management
82
78
  ```
83
79
 
84
80
  ## String operations
@@ -129,77 +125,12 @@ t[:birthdate].month.to_sql
129
125
 
130
126
  t[:birthdate].year.to_sql
131
127
  # => YEAR(my_table.birthdate)
132
- ```
133
-
134
- ### Datetime
135
-
136
- ```ruby
137
- # datetime difference
138
- t[:birthdate] - Time.utc(2014, 3, 3, 12, 41, 18)
139
-
140
- # comparison
141
- t[:birthdate] >= '2014-03-03 10:10:10'
142
- ```
143
-
144
- ### Format and Time Zone Conversion
145
-
146
- `format` has two forms:
147
128
 
148
- ```ruby
149
129
  t[:birthdate].format('%Y-%m-%d').to_sql
150
130
  # => DATE_FORMAT(my_table.birthdate, '%Y-%m-%d')
151
131
  ```
152
132
 
153
- Which formats the datetime without any time zone conversion.
154
- The second form accepts 2 kinds of values:
155
-
156
- 1. String:
157
-
158
- ```ruby
159
- t[:birthdate].format('%Y/%m/%d %H:%M:%S', 'posix/Pacific/Tahiti')
160
- # => DATE_FORMAT(CONVERT_TZ(CAST(my_table.birthdate AS datetime), 'UTC', 'posix/Pacific/Tahiti'), '%Y/%m/%d %H:%i:%S') ## MySQL
161
- # => TO_CHAR(CAST(my_table.birthdate AS timestamp with time zone) AT TIME ZONE 'posix/Pacific/Tahiti', 'YYYY/MM/DD HH24:MI:SS') ## PostgreSQL
162
- # => CONVERT(datetime, my_table.birthdate) AT TIME ZONE 'UTC' AT TIME ZONE N'posix/Pacific/Tahiti' ## SQL Server (& truncated for clarity)
163
- # ^^^^^^^^^^^^^^^^^^^^ 🚨 Invalid timezone for SQL Server. Explanation below.
164
- ```
165
-
166
- which will convert the datetime field to the supplied time zone. This generally
167
- means that you're letting the RDBMS decide or infer what is the timezone of the
168
- column before conversion to the supplied timezone.
169
-
170
- 1. Hash of the form `{ src_time_zone => dst_time_zone }`:
171
-
172
- ```ruby
173
- t[:birthdate].format('%Y/%m/%d %H:%M:%S', { 'posix/Europe/Paris' => 'posix/Pacific/Tahiti' })
174
- ```
175
-
176
- which will explicitly indicate the original timestamp that should be considered
177
- by the RDBMS.
178
-
179
- Warning:
180
-
181
- - ⚠️ Time Zone names are specific to each RDBMS. While `PostgreSQL` and `MySQL`
182
- have overlaping names (the ones prefixed with `posix`), you should always
183
- read your vendor's documentation. `SQL Server` is a black sheep and has its
184
- own conventions.
185
- - ⚠️ Daylight saving is managed by the RDBMS vendor. Choose the approptiate time
186
- zone name that enforces proper daylight saving conversions.
187
- - ☣️ Choosing `GMT+offset` will certainly bypass daylight saving computations.
188
- - ☣️ Choosing abbreviate forms like `CET`, which stands for `Central European
189
- Time` will behave differently on `PostgreSQL` and `MySQL`. Don't assume
190
- uniform behavior, or even a _rational_ one.
191
- - ⚠️ Pay attention to the type of the `datetime` column you're working with. For
192
- example, in Postgres, a `datetime` can be one of the following types:
193
- 1. `timestamp with time zone`
194
- 2. `timestamp without time zone`
195
- In the first case, you don't need to supply a conversion hash because postgres
196
- knows how to convert it to the desired time zone. However, if you do the same
197
- for the second case, you might get surprises, especially if your Postgres
198
- installation's default timezone is not `UTC`.
199
- - ⚠️ SQLite is not supported.
200
- - 🚨 Always test against your setup 🚨
201
-
202
- ## Unions
133
+ ## Unions
203
134
 
204
135
  ```ruby
205
136
  (t.where(t[:name].eq('str')) + t.where(t[:name].eq('test'))).to_sql
@@ -212,7 +143,7 @@ Arel-extensions allows to use functions on case clause
212
143
 
213
144
  ```ruby
214
145
  t[:name].when("smith").then(1).when("doe").then(2).else(0).sum.to_sql
215
- # => SUM(CASE "my_table"."name" WHEN 'smith' THEN 1 WHEN 'doe' THEN 2 ELSE 0 END)
146
+ # => SUM(CASE "my_table"."name" WHEN 'smith' THEN 1 WHEN 'doe' THEN 2 ELSE 0 END)
216
147
  ```
217
148
 
218
149
  ## Cast Function
@@ -229,7 +160,7 @@ t[:id].cast('char').to_sql
229
160
 
230
161
  To optimize queries, some classical functions are defined in databases missing any alternative native functions.
231
162
  Examples :
232
- - FIND_IN_SET
163
+ - FIND_IN_SET
233
164
 
234
165
  ## BULK INSERT / UPSERT
235
166
 
@@ -278,7 +209,7 @@ User.connection.execute(insert_manager.to_sql)
278
209
  <td class="tg-yw4l">CEIL<br>column.ceil</td>
279
210
  <td class="ok">✔</td>
280
211
  <td class="ok">✔</td>
281
- <td class="tg-j6lv">CASE + CAST</td>
212
+ <td class="tg-j6lv">CASE + ROUND</td>
282
213
  <td class="ok">✔</td>
283
214
  <td class="tg-j6lv">CEILING()</td>
284
215
  <td class="tg-j6lv">CEILING()</td>
@@ -287,7 +218,7 @@ User.connection.execute(insert_manager.to_sql)
287
218
  <td class="tg-yw4l">FLOOR<br>column.floor</td>
288
219
  <td class="ok">✔</td>
289
220
  <td class="ok">✔</td>
290
- <td class="tg-j6lv">CASE + CAST</td>
221
+ <td class="tg-j6lv">CASE + ROUND</td>
291
222
  <td class="ok">✔</td>
292
223
  <td class="ok">✔</td>
293
224
  <td class="ok">✔</td>
@@ -454,7 +385,7 @@ User.connection.execute(insert_manager.to_sql)
454
385
  <td class="ok">✔</td>
455
386
  <td class="tg-j6lv">✔</td>
456
387
  <td class="tg-j6lv">?</td>
457
- </tr>
388
+ </tr>
458
389
  <tr>
459
390
  <td class="tg-yw4l">Matching Accent Insensitive<br>column.ai_matches('blah')</td>
460
391
  <td class="ok">not supported</td>
@@ -463,7 +394,7 @@ User.connection.execute(insert_manager.to_sql)
463
394
  <td class="ok">not supported</td>
464
395
  <td class="tg-j6lv">✔</td>
465
396
  <td class="tg-j6lv">?</td>
466
- </tr>
397
+ </tr>
467
398
  <tr>
468
399
  <td class="tg-yw4l">Matching Case Insensitive<br>column.imatches('blah')</td>
469
400
  <td class="ok">not supported</td>
@@ -472,7 +403,7 @@ User.connection.execute(insert_manager.to_sql)
472
403
  <td class="ok">✔</td>
473
404
  <td class="tg-j6lv">✔</td>
474
405
  <td class="tg-j6lv">?</td>
475
- </tr>
406
+ </tr>
476
407
  <tr>
477
408
  <td class="tg-yw4l">Matching Accent/Case Sensitive<br>column.smatches('blah')</td>
478
409
  <td class="ok">✔</td>
@@ -481,8 +412,8 @@ User.connection.execute(insert_manager.to_sql)
481
412
  <td class="ok">✔</td>
482
413
  <td class="tg-j6lv">✔</td>
483
414
  <td class="tg-j6lv">?</td>
484
- </tr>
485
-
415
+ </tr>
416
+
486
417
  <tr>
487
418
  <th class="tg-4rp9" rowspan="6"><div>Date functions</div></th>
488
419
  <td class="tg-yw4l">DATEADD<br>column + 2.year<br></td>
@@ -660,45 +591,3 @@ User.connection.execute(insert_manager.to_sql)
660
591
  </tr>
661
592
  </tbody>
662
593
  </table>
663
-
664
- ## Version Compatibility
665
-
666
- <table>
667
- <tr><th>Ruby</th> <th>Rails</th> <th>Arel Extensions</th></tr>
668
- <tr><td>3.1</td> <td>6.1</td> <td>2</td></tr>
669
- <tr><td>3.0</td> <td>6.1</td> <td>2</td></tr>
670
- <tr><td>2.7</td> <td>6.1, 6.0</td> <td>2</td></tr>
671
- <tr><td>2.5</td> <td>6.1, 6.0</td> <td>2</td></tr>
672
- <tr><td>2.5</td> <td>5.2</td> <td>1</td></tr>
673
- </table>
674
-
675
- ## Development
676
-
677
- Let's say you want to develop/test for `ruby 2.7.5` and `rails 5.2`.
678
-
679
- You will need to fix your ruby version:
680
-
681
- ```bash
682
- rbenv install 2.7.5
683
- rbenv local 2.7.5
684
- ```
685
-
686
- Fix your gemfiles:
687
-
688
- ```bash
689
- bundle config set --local gemfile ./gemfiles/rails6.gemfile
690
- ```
691
-
692
- Install dependencies:
693
- ```bash
694
- bundle install
695
- ```
696
-
697
- Develop, then test:
698
-
699
- ```bash
700
- bundle exec rake test:to_sql
701
- ```
702
-
703
- Refer to the [Version Compatibility](#version-compatibility) section to correctly
704
- set your gemfile.
data/Rakefile CHANGED
@@ -1,50 +1,39 @@
1
1
  require 'bundler'
2
- Bundler::GemHelper.install_tasks name: 'arel_extensions'
2
+ Bundler::GemHelper.install_tasks :name => "arel_extensions"
3
3
 
4
4
  require 'rake/testtask'
5
5
 
6
- desc 'Default Task'
7
- task default: [:test]
6
+ desc "Default Task"
7
+ task default: [ :test ]
8
8
 
9
9
  Rake::TestTask.new(:test) do |t|
10
- t.libs << 'lib'
11
- t.libs << 'test'
12
- t.pattern = 'test/**/test_*.rb'
13
- t.warning = true
14
- t.verbose = true
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/test_*.rb'
13
+ t.warning = true
14
+ t.verbose = true
15
15
  end
16
16
 
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|
29
- namespace :test do
30
- Rake::TestTask.new(adapter => "#{adapter}:env") { |t|
31
- t.libs << 'lib'
32
- t.libs << 'test'
33
- t.pattern = 'test/with_ar/*_agnostic_test.rb'
34
- t.warning = false
35
- t.verbose = true
36
- t.ruby_opts = ['--dev'] if defined?(JRUBY_VERSION)
37
- }
38
- end
39
-
40
- namespace adapter do
41
- task test: "test_#{adapter}"
42
- task isolated_test: "isolated_test_#{adapter}"
43
-
44
- # Set the connection environment for the adapter
45
- task(:env) { ENV['DB'] = adapter }
46
- end
47
-
48
- # Make sure the adapter test evaluates the env setting task
49
- task "test_#{adapter}" => ["#{adapter}:env", "test:#{adapter}"]
17
+ %w(mysql postgresql sqlite ibm_db oracle mssql).each do |adapter|
18
+ namespace :test do
19
+ Rake::TestTask.new(adapter => "#{adapter}:env") { |t|
20
+ t.libs << 'lib'
21
+ t.libs << 'test'
22
+ t.pattern = 'test/with_ar/*_agnostic_test.rb'
23
+ t.warning = true
24
+ t.verbose = true
25
+ t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
26
+ }
27
+ end
28
+
29
+ namespace adapter do
30
+ task :test => "test_#{adapter}"
31
+ task :isolated_test => "isolated_test_#{adapter}"
32
+
33
+ # Set the connection environment for the adapter
34
+ task(:env) { ENV['DB'] = adapter }
35
+ end
36
+
37
+ # Make sure the adapter test evaluates the env setting task
38
+ task "test_#{adapter}" => ["#{adapter}:env", "test:#{adapter}"]
50
39
  end
data/TODO CHANGED
@@ -1,6 +1,7 @@
1
1
  Code quality:
2
2
  + codeclimate.com
3
3
  + gemnasium
4
+ + appveyor.com (windows)
4
5
  + hakiri.io
5
6
  - coveralls.io
6
7
  - inch-ci.org
data/appveyor.yml ADDED
@@ -0,0 +1,44 @@
1
+ version: "{build}"
2
+
3
+ cache:
4
+ - vendor/bundle
5
+
6
+ branches:
7
+ only:
8
+ - master
9
+
10
+ services:
11
+ - mssql2014
12
+
13
+
14
+ install:
15
+ - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
16
+ - bundle config --local path vendor/bundle
17
+ - bundle install
18
+
19
+ # Disable normal Windows builds in favor of our test script.
20
+ build: off
21
+
22
+
23
+ before_test:
24
+ - ruby -v
25
+ - gem -v
26
+ - bundle -v
27
+
28
+ test_script:
29
+ - ruby --version
30
+ - gem --version
31
+ - bundler --version
32
+ - bundle exec rake test
33
+ - ps: Start-Service 'MSSQL$SQL2014'
34
+ - timeout /t 4 /nobreak > NUL
35
+ - bundle exec rake test:mssql
36
+
37
+ environment:
38
+ matrix:
39
+ - RUBY_VERSION: 200
40
+ - RUBY_VERSION: 21
41
+ - RUBY_VERSION: 22
42
+ - RUBY_VERSION: 23
43
+ - RUBY_VERSION: 23-x64
44
+
@@ -1,28 +1,28 @@
1
- $:.push File.expand_path('../lib', __FILE__)
2
- require 'arel_extensions/version'
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "arel_extensions/version"
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.name = 'arel_extensions'
5
+ s.name = "arel_extensions"
6
6
  s.version = ArelExtensions::VERSION
7
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'
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
13
  s.license = 'MIT'
14
14
 
15
- s.rdoc_options = ['--main', 'README.md']
16
- s.extra_rdoc_files = ['MIT-LICENSE.txt', 'README.md', 'functions.html']
15
+ s.rdoc_options = ["--main", "README.md"]
16
+ s.extra_rdoc_files = ["MIT-LICENSE.txt", "README.md", 'functions.html']
17
17
 
18
18
  # Manifest
19
19
  s.files = `git ls-files`.split("\n")
20
20
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
- s.require_paths = ['lib']
21
+ s.require_paths = ["lib"]
22
22
 
23
- s.add_dependency('arel', '>= 6.0')
23
+ s.add_dependency('activerecord', '>= 6.0.0.rc2')
24
24
 
25
25
  s.add_development_dependency('minitest', '~> 5.9')
26
- s.add_development_dependency('rdoc', '>= 6.3.1')
27
- s.add_development_dependency('rake', '~> 12.3.3')
26
+ s.add_development_dependency('rdoc', '~> 4.0')
27
+ s.add_development_dependency('rake', '~> 11')
28
28
  end
data/functions.html CHANGED
@@ -55,7 +55,7 @@
55
55
  <td class="tg-yw4l">CEIL<br>column.ceil</td>
56
56
  <td class="ok">✔</td>
57
57
  <td class="ok">✔</td>
58
- <td class="tg-j6lv">CASE + CAST</td>
58
+ <td class="tg-j6lv">CASE + ROUND</td>
59
59
  <td class="ok">✔</td>
60
60
  <td class="tg-j6lv">CEILING()</td>
61
61
  <td class="tg-j6lv">CEILING()</td>
@@ -64,7 +64,7 @@
64
64
  <td class="tg-yw4l">FLOOR<br>column.floor</td>
65
65
  <td class="ok">✔</td>
66
66
  <td class="ok">✔</td>
67
- <td class="tg-j6lv">CASE + CAST</td>
67
+ <td class="tg-j6lv">CASE + ROUND</td>
68
68
  <td class="ok">✔</td>
69
69
  <td class="ok">✔</td>
70
70
  <td class="ok">✔</td>
@@ -379,7 +379,7 @@
379
379
  <td class="ok">✔</td>
380
380
  <td class="ok">✔</td>
381
381
  <td class="ok">✔</td>
382
- </tr>
382
+ </tr>
383
383
  <tr>
384
384
  <th class="bulk_insert" rowspan="1"><div>Set<br/> Operators</div></th>
385
385
  <td class="tg-yw4l">UNION ( + )<br/>query + query</td>
@@ -1,20 +1,20 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gem 'arel', '~> 3.0' # too old...
4
4
 
5
5
  group :development, :test do
6
- gem 'sqlite3', '<= 1.3.13', platform: [:ruby, :mswin, :mingw]
7
- gem 'mysql2', '0.4.10', platform: [:ruby, :mswin, :mingw]
8
- gem 'activerecord-mysql2-adapter', platform: [:ruby, :mswin, :mingw]
9
- gem 'pg', platform: [:ruby, :mswin, :mingw]
6
+ gem "sqlite3", '<= 1.3.13', :platform => [:ruby, :mswin, :mingw]
7
+ gem "mysql2", '0.4.10', :platform => [:ruby, :mswin, :mingw]
8
+ gem "activerecord-mysql2-adapter", :platform => [:ruby, :mswin, :mingw]
9
+ gem "pg", :platform => [:ruby, :mswin, :mingw]
10
10
  # for JRuby
11
- gem 'jdbc-sqlite3', platform: :jruby
12
- gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
13
- gem 'activerecord-jdbcmysql-adapter', platform: :jruby
14
- gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
11
+ gem "jdbc-sqlite3", :platform => :jruby
12
+ gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
13
+ gem "activerecord-jdbcmysql-adapter", :platform => :jruby
14
+ gem "activerecord-jdbcpostgresql-adapter", :platform => :jruby
15
15
  gem 'activesupport', '~> 3.2'
16
16
  gem 'activemodel', '~> 3.2'
17
17
  gem 'activerecord', '~> 3.2'
18
18
  end
19
19
 
20
- gemspec path: '../'
20
+ gemspec :path => "../"
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gem 'arel', '~> 6.0'
4
4
 
@@ -7,23 +7,23 @@ group :development, :test do
7
7
  gem 'activemodel', '~> 4.0'
8
8
  gem 'activerecord', '~> 4.0'
9
9
 
10
- gem 'sqlite3', '<= 1.3.13', platforms: [:mri, :mswin, :mingw]
11
- gem 'mysql2', '0.4.10', platforms: [:mri, :mswin, :mingw]
12
- gem 'pg', '< 1.0.0', platforms: [:mri, :mingw]
10
+ gem "sqlite3", '<= 1.3.13', :platforms => [:mri, :mswin, :mingw]
11
+ gem "mysql2", '0.4.10', :platforms => [:mri, :mswin, :mingw]
12
+ gem "pg",'< 1.0.0', :platforms => [:mri, :mingw]
13
13
 
14
- gem 'tiny_tds', platforms: [:mri, :mingw, :mswin] if RUBY_PLATFORM =~ /windows/
15
- gem 'activerecord-sqlserver-adapter', '~> 4.2.0', platforms: [:mri, :mingw, :mswin] if RUBY_PLATFORM =~ /windows/
14
+ gem "tiny_tds", :platforms => [:mri, :mingw, :mswin] if RUBY_PLATFORM =~ /windows/
15
+ gem "activerecord-sqlserver-adapter", '~> 4.2.0', :platforms => [:mri, :mingw, :mswin] if RUBY_PLATFORM =~ /windows/
16
16
 
17
- gem 'ruby-oci8', platforms: [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
17
+ gem 'ruby-oci8', :platforms => [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
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', '~> 1.3', platforms: :jruby
22
- gem 'jdbc-sqlite3', platforms: :jruby
23
- gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
24
- gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
25
- gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
26
- gem 'activerecord-jdbcmssql-adapter', platforms: :jruby
21
+ gem 'activerecord-jdbc-adapter', :platforms => :jruby
22
+ gem "jdbc-sqlite3", :platforms => :jruby
23
+ gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
24
+ gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
25
+ gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
26
+ gem "activerecord-jdbcmssql-adapter", :platforms => :jruby
27
27
  end
28
28
 
29
- gemspec path: '../'
29
+ gemspec :path => "../"
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gem 'arel', '~> 7.0'
4
4
 
@@ -7,23 +7,23 @@ group :development, :test do
7
7
  gem 'activemodel', '~> 5.0'
8
8
  gem 'activerecord', '5.0.6'
9
9
 
10
- gem 'sqlite3', '<= 1.3.13', platforms: [:mri, :mswin, :mingw]
11
- gem 'mysql2', '0.4.10', platforms: [:mri, :mswin, :mingw]
12
- gem 'pg', '< 1.0.0', platforms: [:mri, :mingw]
10
+ gem "sqlite3", '<= 1.3.13', :platforms => [:mri, :mswin, :mingw]
11
+ gem "mysql2", '0.4.10', :platforms => [:mri, :mswin, :mingw]
12
+ gem "pg",'< 1.0.0', :platforms => [:mri, :mingw]
13
13
 
14
- gem 'tiny_tds', platforms: [:mri, :mingw] if RUBY_PLATFORM =~ /windows/
15
- # gem "activerecord-sqlserver-adapter", platforms: [:mri, :mingw]
14
+ gem "tiny_tds", :platforms => [:mri, :mingw] if RUBY_PLATFORM =~ /windows/
15
+ #gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw]
16
16
 
17
- gem 'ruby-oci8', platforms: [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
17
+ gem 'ruby-oci8', :platforms => [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
18
18
  gem 'activerecord-oracle_enhanced-adapter', '~> 1.7' if ENV.has_key? 'ORACLE_HOME'
19
19
 
20
20
  # for JRuby
21
- gem 'activerecord-jdbc-adapter', github: 'jruby/activerecord-jdbc-adapter', tag: 'v50.0', platforms: :jruby
22
- gem 'jdbc-sqlite3', platforms: :jruby
23
- gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
24
- gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
25
- gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
26
- gem 'activerecord-jdbcmssql-adapter', platforms: :jruby
21
+ gem 'activerecord-jdbc-adapter', :github => 'jruby/activerecord-jdbc-adapter', :tag => 'v50.0', :platforms => :jruby
22
+ gem "jdbc-sqlite3", :platforms => :jruby
23
+ gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
24
+ gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
25
+ gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
26
+ gem "activerecord-jdbcmssql-adapter", :platforms => :jruby
27
27
  end
28
28
 
29
- gemspec path: '../'
29
+ gemspec :path => "../"
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gem 'rails', '5.1.4'
4
4
  gem 'arel', '~> 8'
@@ -8,23 +8,23 @@ group :development, :test do
8
8
  gem 'activemodel', '5.1.4'
9
9
  gem 'activerecord', '5.1.4'
10
10
 
11
- gem 'sqlite3', '<= 1.3.13', platforms: [:mri, :mswin, :mingw]
12
- gem 'mysql2', '0.4.10', platforms: [:mri, :mswin, :mingw]
13
- gem 'pg', '< 1.0.0', platforms: [:mri, :mingw]
11
+ gem "sqlite3", '<= 1.3.13', :platforms => [:mri, :mswin, :mingw]
12
+ gem "mysql2", '0.4.10', :platforms => [:mri, :mswin, :mingw]
13
+ gem "pg",'< 1.0.0', :platforms => [:mri, :mingw]
14
14
 
15
- gem 'tiny_tds', platforms: [:mri, :mingw] if RUBY_PLATFORM =~ /windows/
16
- # gem "activerecord-sqlserver-adapter", platforms: [:mri, :mingw]
15
+ gem "tiny_tds", :platforms => [:mri, :mingw] if RUBY_PLATFORM =~ /windows/
16
+ #gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw]
17
17
 
18
- gem 'ruby-oci8', platforms: [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
18
+ gem 'ruby-oci8', :platforms => [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
19
19
  gem 'activerecord-oracle_enhanced-adapter', '~> 1.8' if ENV.has_key? 'ORACLE_HOME'
20
20
 
21
21
  # for JRuby
22
- gem 'activerecord-jdbc-adapter', github: 'jruby/activerecord-jdbc-adapter', tag: 'v51.0', 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
22
+ gem 'activerecord-jdbc-adapter', :github => 'jruby/activerecord-jdbc-adapter', :tag => 'v51.0', :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
28
  end
29
29
 
30
- gemspec path: '../'
30
+ gemspec :path => "../"