arel_extensions 1.3.8 → 2.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +2 -1
  3. data/.gitignore +6 -7
  4. data/.rubocop.yml +3 -67
  5. data/.travis/oracle/download.js +152 -0
  6. data/.travis/oracle/download.sh +30 -0
  7. data/.travis/oracle/download_ojdbc.js +116 -0
  8. data/.travis/oracle/install.sh +34 -0
  9. data/.travis/setup_accounts.sh +9 -0
  10. data/.travis/sqlite3/extension-functions.sh +6 -0
  11. data/.travis.yml +223 -0
  12. data/Gemfile +21 -16
  13. data/README.md +90 -282
  14. data/Rakefile +30 -48
  15. data/TODO +1 -0
  16. data/appveyor.yml +22 -60
  17. data/arel_extensions.gemspec +14 -13
  18. data/functions.html +3 -3
  19. data/gemfiles/rails3.gemfile +10 -10
  20. data/gemfiles/rails4.gemfile +29 -0
  21. data/gemfiles/rails5_0.gemfile +29 -0
  22. data/gemfiles/rails5_1_4.gemfile +14 -14
  23. data/gemfiles/rails5_2.gemfile +14 -16
  24. data/init/mssql.sql +4 -4
  25. data/init/mysql.sql +38 -38
  26. data/init/oracle.sql +0 -0
  27. data/init/postgresql.sql +21 -21
  28. data/init/sqlite.sql +0 -0
  29. data/lib/arel_extensions/attributes.rb +3 -4
  30. data/lib/arel_extensions/boolean_functions.rb +14 -53
  31. data/lib/arel_extensions/common_sql_functions.rb +17 -16
  32. data/lib/arel_extensions/comparators.rb +28 -27
  33. data/lib/arel_extensions/date_duration.rb +13 -17
  34. data/lib/arel_extensions/insert_manager.rb +15 -18
  35. data/lib/arel_extensions/math.rb +53 -55
  36. data/lib/arel_extensions/math_functions.rb +39 -46
  37. data/lib/arel_extensions/nodes/abs.rb +1 -0
  38. data/lib/arel_extensions/nodes/blank.rb +2 -1
  39. data/lib/arel_extensions/nodes/case.rb +19 -20
  40. data/lib/arel_extensions/nodes/cast.rb +8 -10
  41. data/lib/arel_extensions/nodes/ceil.rb +1 -1
  42. data/lib/arel_extensions/nodes/coalesce.rb +4 -3
  43. data/lib/arel_extensions/nodes/collate.rb +10 -9
  44. data/lib/arel_extensions/nodes/concat.rb +18 -9
  45. data/lib/arel_extensions/nodes/date_diff.rb +26 -42
  46. data/lib/arel_extensions/nodes/duration.rb +3 -0
  47. data/lib/arel_extensions/nodes/find_in_set.rb +1 -0
  48. data/lib/arel_extensions/nodes/floor.rb +1 -1
  49. data/lib/arel_extensions/nodes/format.rb +8 -35
  50. data/lib/arel_extensions/nodes/formatted_number.rb +23 -22
  51. data/lib/arel_extensions/nodes/function.rb +37 -42
  52. data/lib/arel_extensions/nodes/is_null.rb +0 -0
  53. data/lib/arel_extensions/nodes/json.rb +39 -52
  54. data/lib/arel_extensions/nodes/length.rb +0 -5
  55. data/lib/arel_extensions/nodes/levenshtein_distance.rb +1 -1
  56. data/lib/arel_extensions/nodes/locate.rb +2 -1
  57. data/lib/arel_extensions/nodes/log10.rb +2 -1
  58. data/lib/arel_extensions/nodes/matches.rb +7 -5
  59. data/lib/arel_extensions/nodes/md5.rb +1 -0
  60. data/lib/arel_extensions/nodes/power.rb +5 -5
  61. data/lib/arel_extensions/nodes/rand.rb +1 -0
  62. data/lib/arel_extensions/nodes/repeat.rb +5 -3
  63. data/lib/arel_extensions/nodes/replace.rb +8 -16
  64. data/lib/arel_extensions/nodes/round.rb +6 -5
  65. data/lib/arel_extensions/nodes/soundex.rb +15 -15
  66. data/lib/arel_extensions/nodes/std.rb +21 -18
  67. data/lib/arel_extensions/nodes/substring.rb +16 -8
  68. data/lib/arel_extensions/nodes/then.rb +1 -1
  69. data/lib/arel_extensions/nodes/trim.rb +6 -4
  70. data/lib/arel_extensions/nodes/union.rb +8 -5
  71. data/lib/arel_extensions/nodes/union_all.rb +7 -4
  72. data/lib/arel_extensions/nodes/wday.rb +4 -0
  73. data/lib/arel_extensions/nodes.rb +1 -1
  74. data/lib/arel_extensions/null_functions.rb +5 -19
  75. data/lib/arel_extensions/predications.rb +43 -44
  76. data/lib/arel_extensions/railtie.rb +5 -5
  77. data/lib/arel_extensions/set_functions.rb +7 -5
  78. data/lib/arel_extensions/string_functions.rb +29 -59
  79. data/lib/arel_extensions/tasks.rb +6 -6
  80. data/lib/arel_extensions/version.rb +1 -1
  81. data/lib/arel_extensions/visitors/ibm_db.rb +31 -24
  82. data/lib/arel_extensions/visitors/mssql.rb +180 -375
  83. data/lib/arel_extensions/visitors/mysql.rb +212 -350
  84. data/lib/arel_extensions/visitors/oracle.rb +178 -220
  85. data/lib/arel_extensions/visitors/oracle12.rb +31 -18
  86. data/lib/arel_extensions/visitors/postgresql.rb +173 -256
  87. data/lib/arel_extensions/visitors/sqlite.rb +126 -140
  88. data/lib/arel_extensions/visitors/to_sql.rb +237 -298
  89. data/lib/arel_extensions/visitors.rb +58 -82
  90. data/lib/arel_extensions.rb +31 -182
  91. data/test/database.yml +7 -15
  92. data/test/helper.rb +18 -0
  93. data/test/real_db_test.rb +116 -105
  94. data/test/support/fake_record.rb +3 -3
  95. data/test/test_comparators.rb +17 -14
  96. data/test/visitors/test_bulk_insert_oracle.rb +11 -11
  97. data/test/visitors/test_bulk_insert_sqlite.rb +13 -12
  98. data/test/visitors/test_bulk_insert_to_sql.rb +13 -11
  99. data/test/visitors/test_oracle.rb +55 -55
  100. data/test/visitors/test_to_sql.rb +226 -419
  101. data/test/with_ar/all_agnostic_test.rb +365 -709
  102. data/test/with_ar/insert_agnostic_test.rb +21 -27
  103. data/test/with_ar/test_bulk_sqlite.rb +16 -17
  104. data/test/with_ar/test_math_sqlite.rb +26 -26
  105. data/test/with_ar/test_string_mysql.rb +33 -31
  106. data/test/with_ar/test_string_sqlite.rb +34 -30
  107. metadata +34 -33
  108. data/.github/workflows/ruby.yml +0 -360
  109. data/NEWS.md +0 -32
  110. data/dev/compose.yaml +0 -29
  111. data/gemfiles/rails4_2.gemfile +0 -38
  112. data/gemfiles/rails5.gemfile +0 -29
  113. data/gemfiles/rails6.gemfile +0 -30
  114. data/gemfiles/rails6_1.gemfile +0 -30
  115. data/gemfiles/rails7.gemfile +0 -23
  116. data/gemfiles/rails7_1.gemfile +0 -22
  117. data/gemspecs/arel_extensions-v1.gemspec +0 -27
  118. data/gemspecs/arel_extensions-v2.gemspec +0 -27
  119. data/generate_gems.sh +0 -15
  120. data/lib/arel_extensions/aliases.rb +0 -14
  121. data/lib/arel_extensions/helpers.rb +0 -57
  122. data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
  123. data/lib/arel_extensions/nodes/formatted_date.rb +0 -42
  124. data/lib/arel_extensions/nodes/rollup.rb +0 -36
  125. data/lib/arel_extensions/nodes/select.rb +0 -10
  126. data/lib/arel_extensions/nodes/sum.rb +0 -7
  127. data/lib/arel_extensions/visitors/convert_format.rb +0 -37
  128. data/test/arelx_test_helper.rb +0 -67
  129. data/version_v1.rb +0 -3
  130. data/version_v2.rb +0 -3
data/.travis.yml ADDED
@@ -0,0 +1,223 @@
1
+ language: ruby
2
+ sudo: required
3
+ cache:
4
+ bundler: true
5
+ directories:
6
+ - $ORACLE_HOME
7
+ before_install:
8
+ - chmod +x .travis/sqlite3/extension-functions.sh
9
+ # - chmod +x .travis/oracle/download.sh
10
+ # - chmod +x .travis/oracle/install.sh
11
+ # - chmod +x .travis/setup_accounts.sh
12
+ - sudo apt-get install -y sqlite3-pcre curl
13
+ - .travis/sqlite3/extension-functions.sh
14
+ # - .travis/oracle/download.sh
15
+ # - sh -ex .travis/oracle/install.sh
16
+ # - .travis/setup_accounts.sh
17
+ install:
18
+ - gem install bundler -v 1.17.3
19
+ - bundle install
20
+ gemfile:
21
+ - gemfiles/rails4.gemfile
22
+ - gemfiles/rails5_0.gemfile
23
+ - gemfiles/rails5_1_4.gemfile
24
+ - gemfiles/rails5_2.gemfile
25
+ services:
26
+ - mysql
27
+ - postgresql
28
+ before_script:
29
+ - mysql -e 'create database arext_test;'
30
+ - psql -c 'create database arext_test;' -U postgres
31
+ script:
32
+ - gem build arel_extensions.gemspec
33
+ - bundle exec rake test
34
+ - bundle exec rake test:sqlite
35
+ - bundle exec rake test:mysql
36
+ - bundle exec rake test:postgresql
37
+ #- bundle exec rake test:oracle # service unavailable
38
+ env:
39
+ global:
40
+ - JRUBY_OPTS='--dev -J-Xmx1024M'
41
+ # - ORACLE_COOKIE=sqldev
42
+ # - ORACLE_FILE=oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
43
+ # - ORACLE_OJDBC_URL=http://download.oracle.com/otn/utilities_drivers/jdbc/11204/ojdbc6.jar
44
+ - TNS_ADMIN=$ORACLE_HOME/network/admin
45
+ # - ORACLE_BASE=/u01/app/oracle
46
+ # - ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
47
+ # - ORACLE_SID=XE
48
+ - DATABASE_NAME=XE
49
+ - NLS_LANG=AMERICAN_AMERICA.AL32UTF8
50
+ - secure: 0RUuF4l0e3J8UIIMlgb8x/aYy2pH6Wb+EWylOr2W1EQechivoFw6IEYD1EZWIOZ/uNpkQ2h/urbUqW3/HpKhZn+NYP2sQI41Xyu1TD+6HPWAHpEvLzemhQSJV6eIeLRQoVDLUmqF23nUZDtKQAwOOyJVMeqHMahJi5K7N/cfQmifs2QcBnMxPnANIcrSXxOCBoqCl6BERG9JTeKERG/lWG1I9vRIe9ISNyOPUQVVI6SfTJwhJP5NLkxSJG1q2PLPK7p6zQ684sS4zSnS5oV23yDsQWWIwxk78CVu1jnFBu8Qq3ngWsInlkHrPotjtaxmTxM8JQd4fgE5NMO2Pjnj8w7zg+sbl+3OVtareX+M9+OLdUD5xBQhecPpzflMqib2qZ0fr9tdoT8kAZJTiXtQrptZfaXleZlH74l2dO/PYxkoWMusYQnSbQl0G3AoyYH+l7YpefL4arm0s5IIiOK+ZiCoZ14pl26rYAA1iPUe5AT+hecKi+fwqhyFE7fMX+zC+AvzsQL8jrP0CXL/hmPkoFYxvcDgUoYhvOq+mmQHdOfU7ny4hH5z5d9691qceduHFvF7fNZ4pSofj03eGqfTTk+SDNeZIo6NXNlayayjV2L/DxL6d7vetxkWwipx47PI76gBAqJlxgODJuzoOtyQkPyIVsDlzI1UPoS+UbrU51w=
51
+ rvm:
52
+ - 2.0.0
53
+ - 2.1
54
+ - 2.2.5
55
+ - 2.3.1
56
+ - 2.4.0
57
+ - 2.5.0
58
+ - rbx-2
59
+ - jruby-9.0.5.0
60
+ - jruby-9.2.0.0
61
+ - jruby-head
62
+ - ruby-head
63
+ jdk:
64
+ - openjdk7
65
+ - oraclejdk8
66
+ - oraclejdk9
67
+ - openjdk10
68
+ - oraclejdk10
69
+ - openjdk11
70
+ - oraclejdk11
71
+ matrix:
72
+ fast_finish: true
73
+ exclude:
74
+ - rvm: rbx-2
75
+ jdk: openjdk7
76
+ - 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
110
+ - rvm: 2.1
111
+ jdk: oraclejdk10
112
+ - rvm: 2.2.5
113
+ jdk: oraclejdk10
114
+ - rvm: 2.3.1
115
+ jdk: oraclejdk10
116
+ - rvm: 2.4.0
117
+ jdk: oraclejdk10
118
+ - rvm: 2.5.0
119
+ jdk: oraclejdk10
120
+ - rvm: ruby-head
121
+ jdk: oraclejdk10
122
+ - rvm: rbx-2
123
+ jdk: openjdk10
124
+ - rvm: 2.0.0
125
+ jdk: openjdk10
126
+ - rvm: 2.1
127
+ jdk: openjdk10
128
+ - rvm: 2.2.5
129
+ jdk: openjdk10
130
+ - rvm: 2.3.1
131
+ jdk: openjdk10
132
+ - rvm: 2.4.0
133
+ jdk: openjdk10
134
+ - rvm: 2.5.0
135
+ jdk: openjdk10
136
+ - rvm: ruby-head
137
+ jdk: openjdk10
138
+ - rvm: rbx-2
139
+ jdk: oraclejdk11
140
+ - rvm: 2.0.0
141
+ jdk: oraclejdk11
142
+ - rvm: 2.1
143
+ jdk: oraclejdk11
144
+ - rvm: 2.2.5
145
+ jdk: oraclejdk11
146
+ - rvm: 2.3.1
147
+ jdk: oraclejdk11
148
+ - rvm: 2.4.0
149
+ jdk: oraclejdk11
150
+ - rvm: 2.5.0
151
+ jdk: oraclejdk11
152
+ - rvm: ruby-head
153
+ jdk: oraclejdk11
154
+ - rvm: rbx-2
155
+ jdk: openjdk11
156
+ - rvm: 2.0.0
157
+ jdk: openjdk11
158
+ - rvm: 2.1
159
+ jdk: openjdk11
160
+ - rvm: 2.2.5
161
+ jdk: openjdk11
162
+ - rvm: 2.3.1
163
+ jdk: openjdk11
164
+ - rvm: 2.4.0
165
+ jdk: openjdk11
166
+ - rvm: 2.5.0
167
+ jdk: openjdk11
168
+ - rvm: ruby-head
169
+ 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
181
+ gemfile: gemfiles/rails4.gemfile
182
+ - rvm: 2.0.0
183
+ gemfile: gemfiles/rails5_0.gemfile
184
+ - rvm: 2.1
185
+ gemfile: gemfiles/rails5_0.gemfile
186
+ - rvm: jruby-9.0.5.0
187
+ gemfile: gemfiles/rails5_1_4.gemfile
188
+ - rvm: 2.0.0
189
+ gemfile: gemfiles/rails5_2.gemfile
190
+ - rvm: 2.1
191
+ 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
200
+ gemfile: gemfiles/rails5_2.gemfile
201
+ - rvm: rbx-2
202
+ gemfile: gemfiles/rails5_1_4.gemfile
203
+ - rvm: jruby-9.0.5.0
204
+ gemfile: gemfiles/rails5_2.gemfile
205
+ - rvm: jruby-9.2.0.0
206
+ jdk: oraclejdk9
207
+ gemfile: gemfiles/rails5_2.gemfile
208
+ - jdk: openjdk10
209
+ - jdk: oraclejdk10
210
+ - jdk: openjdk11
211
+ - jdk: oraclejdk11
212
+ - rvm: ruby-head
213
+ - rvm: jruby-head
214
+ - rvm: jruby-9.2.0.0
215
+ jdk: oraclejdk9
216
+ - rvm: jruby-9.0.5.0
217
+ jdk: oraclejdk9
218
+ bundler_args: "--jobs 3 --retry 2"
219
+ notifications:
220
+ email:
221
+ notifications:
222
+ - julien.delporte@faveod.com
223
+ - yann.azoury@faveod.com
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: %i[mri mingw x64_mingw mswin]
16
- gem 'activerecord-sqlserver-adapter', '~> 6.0', platforms: %i[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: %i[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
+