arel_extensions 1.3.5 → 2.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) 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 +13 -125
  14. data/Rakefile +30 -41
  15. data/TODO +1 -0
  16. data/appveyor.yml +22 -51
  17. data/arel_extensions.gemspec +14 -14
  18. data/functions.html +3 -3
  19. data/gemfiles/rails3.gemfile +10 -10
  20. data/gemfiles/rails4.gemfile +14 -14
  21. data/gemfiles/rails5_0.gemfile +14 -14
  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 +14 -13
  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 +16 -16
  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 -48
  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 +7 -5
  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 -58
  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 +181 -279
  83. data/lib/arel_extensions/visitors/mysql.rb +210 -280
  84. data/lib/arel_extensions/visitors/oracle.rb +180 -201
  85. data/lib/arel_extensions/visitors/oracle12.rb +31 -18
  86. data/lib/arel_extensions/visitors/postgresql.rb +173 -252
  87. data/lib/arel_extensions/visitors/sqlite.rb +126 -140
  88. data/lib/arel_extensions/visitors/to_sql.rb +237 -272
  89. data/lib/arel_extensions/visitors.rb +59 -75
  90. data/lib/arel_extensions.rb +31 -159
  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 +361 -578
  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 +22 -29
  108. data/.github/workflows/ruby.yml +0 -341
  109. data/gemfiles/rails6.gemfile +0 -30
  110. data/gemfiles/rails6_1.gemfile +0 -30
  111. data/gemfiles/rails7.gemfile +0 -23
  112. data/gemspecs/arel_extensions-v1.gemspec +0 -28
  113. data/gemspecs/arel_extensions-v2.gemspec +0 -28
  114. data/generate_gems.sh +0 -15
  115. data/lib/arel_extensions/aliases.rb +0 -14
  116. data/lib/arel_extensions/helpers.rb +0 -51
  117. data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
  118. data/lib/arel_extensions/nodes/sum.rb +0 -7
  119. data/lib/arel_extensions/visitors/convert_format.rb +0 -37
  120. data/test/arelx_test_helper.rb +0 -71
  121. data/version_v1.rb +0 -3
  122. data/version_v2.rb +0 -3
@@ -1,341 +0,0 @@
1
- name: Build and Test
2
-
3
- # Ruby + Rails Compatibility Matrix from here:
4
- # https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
5
-
6
- on: [push, pull_request]
7
-
8
- jobs:
9
- job_build_gem:
10
- name: build
11
- runs-on: ubuntu-latest
12
- strategy:
13
- matrix:
14
- ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
15
- rails: [7, 6_1, 6, 5_2]
16
- exclude: [
17
- {ruby: 3.1, rails: 6 },
18
- {ruby: 3.1, rails: 5_2},
19
- {ruby: 3.0, rails: 6 },
20
- {ruby: 3.0, rails: 5_2},
21
- {ruby: 2.7, rails: 5_2},
22
- {ruby: 2.5, rails: 7 },
23
- {ruby: jruby-9.2, rails: 7 },
24
- {ruby: jruby-9.3, rails: 7 },
25
- ]
26
- steps:
27
- - uses: actions/checkout@v2
28
- - name: Set up Ruby
29
- uses: ruby/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Setup gemspec
33
- if: ${{ matrix.rails != '5_2' }}
34
- run: |
35
- cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
36
- cp ./version_v2.rb lib/arel_extensions/version.rb
37
- cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
38
- - name: Build source gem
39
- run: gem build arel_extensions.gemspec
40
- - name: Upload source gem
41
- uses: actions/upload-artifact@v2
42
- with:
43
- name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
44
- path: "*.gem"
45
-
46
- job_test_to_sql:
47
- name: test to_sql
48
- needs: job_build_gem
49
- runs-on: ubuntu-latest
50
- strategy:
51
- fail-fast: false
52
- matrix:
53
- ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
54
- rails: [7, 6_1, 6, 5_2]
55
- exclude: [
56
- {ruby: 3.1, rails: 6 },
57
- {ruby: 3.1, rails: 5_2},
58
- {ruby: 3.0, rails: 6 },
59
- {ruby: 3.0, rails: 5_2},
60
- {ruby: 2.7, rails: 5_2},
61
- {ruby: 2.5, rails: 7 },
62
- {ruby: jruby-9.2, rails: 7},
63
- {ruby: jruby-9.3, rails: 7},
64
- ]
65
- steps:
66
- - uses: actions/checkout@v2
67
- - name: Set up Ruby
68
- uses: ruby/setup-ruby@v1
69
- with:
70
- ruby-version: ${{ matrix.ruby }}
71
- - name: Install FreeTDS
72
- run: |
73
- sudo apt-get update -q
74
- sudo apt-get install -y freetds-dev
75
- - name: Update system-wide gems
76
- run: gem update --system
77
- - name: Download gem from build job
78
- uses: actions/download-artifact@v2
79
- with:
80
- name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
81
- - name: Setup Gemfile
82
- if: ${{ matrix.rails != '5_2' }}
83
- run: |
84
- cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
85
- cp ./version_v2.rb lib/arel_extensions/version.rb
86
- cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
87
- - name: bundle install
88
- run: |
89
- bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
90
- bundle install
91
- - name: Run test to_sql
92
- run: bundle exec rake test:to_sql
93
-
94
- job_test_sqlite:
95
- name: test sqlite
96
- needs: job_build_gem
97
- runs-on: ubuntu-latest
98
- strategy:
99
- fail-fast: false
100
- matrix:
101
- ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
102
- rails: [7, 6_1, 6, 5_2]
103
- exclude: [
104
- {ruby: 3.1, rails: 6 },
105
- {ruby: 3.1, rails: 5_2},
106
- {ruby: 3.0, rails: 6 },
107
- {ruby: 3.0, rails: 5_2},
108
- {ruby: 2.7, rails: 5_2},
109
- {ruby: 2.5, rails: 7 },
110
- {ruby: jruby-9.2, rails: 7},
111
- {ruby: jruby-9.3, rails: 7},
112
- ]
113
- steps:
114
- - uses: actions/checkout@v2
115
- - name: Set up Ruby
116
- uses: ruby/setup-ruby@v1
117
- with:
118
- ruby-version: ${{ matrix.ruby }}
119
- - name: Install FreeTDS
120
- run: |
121
- sudo apt-get update -q
122
- sudo apt-get install -y freetds-dev
123
- - name: Update system-wide gems
124
- run: gem update --system
125
- - name: Download gem from build job
126
- uses: actions/download-artifact@v2
127
- with:
128
- name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
129
- - name: Setup Gemfile
130
- if: ${{ matrix.rails != '5_2' }}
131
- run: |
132
- cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
133
- cp ./version_v2.rb lib/arel_extensions/version.rb
134
- cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
135
- - name: bundle install
136
- run: |
137
- bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
138
- bundle install
139
- - name: Run test sqlite
140
- run: bundle exec rake test:sqlite
141
-
142
- job_test_postgres:
143
- name: test postgres
144
- needs: job_build_gem
145
- runs-on: ubuntu-latest
146
- strategy:
147
- fail-fast: false
148
- matrix:
149
- ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
150
- rails: [7, 6_1, 6, 5_2]
151
- exclude:
152
- [
153
- { ruby: 3.1, rails: 6 },
154
- { ruby: 3.1, rails: 5_2 },
155
- { ruby: 3.0, rails: 6 },
156
- { ruby: 3.0, rails: 5_2 },
157
- { ruby: 2.7, rails: 5_2 },
158
- { ruby: 2.5, rails: 7 },
159
- { ruby: jruby-9.2, rails: 7 },
160
- { ruby: jruby-9.3, rails: 7 },
161
- ]
162
- steps:
163
- - uses: actions/checkout@v2
164
- # PostgreSQL requires locales to be installed on the system to be able
165
- # to do time and currency conversions at runtime.
166
- #
167
- # That's why we're not launching it as a service; pre-built images
168
- # lack loaclization.
169
- #
170
- # After we install locales, we'll install PostgreSQL binaries and start
171
- # the service.
172
- - name: setup locale
173
- run: |
174
- sudo locale-gen fr_FR.utf8
175
- sudo update-locale
176
- - name: setup postgres 11
177
- run: |
178
- curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
179
- echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
180
- sudo apt update
181
- sudo apt -y install postgresql-11
182
- sudo systemctl enable postgresql
183
- sudo systemctl start postgresql
184
- sudo su -c "psql -c \"alter user postgres with password 'secret'\"" postgres
185
- sudo su -c "createdb arelx_test" postgres
186
- - name: Set up Ruby
187
- uses: ruby/setup-ruby@v1
188
- with:
189
- ruby-version: ${{ matrix.ruby }}
190
- - name: Install FreeTDS
191
- run: |
192
- sudo apt-get update -q
193
- sudo apt-get install -y freetds-dev
194
- - name: Update system-wide gems
195
- run: gem update --system
196
- - name: Download gem from build job
197
- uses: actions/download-artifact@v2
198
- with:
199
- name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
200
- - name: Setup Gemfile
201
- if: ${{ matrix.rails != '5_2' }}
202
- run: |
203
- cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
204
- cp ./version_v2.rb lib/arel_extensions/version.rb
205
- cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
206
- - name: bundle install
207
- run: |
208
- bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
209
- bundle install
210
- - name: Run test Postgres
211
- env:
212
- PGHOST: localhost
213
- PGUSER: postgres
214
- run: bundle exec rake test:postgresql
215
-
216
- job_test_mysql:
217
- name: test mysql
218
- needs: job_build_gem
219
- runs-on: ubuntu-latest
220
- strategy:
221
- fail-fast: false
222
- matrix:
223
- ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
224
- rails: [7, 6_1, 6, 5_2]
225
- exclude: [
226
- {ruby: 3.1, rails: 6 },
227
- {ruby: 3.1, rails: 5_2},
228
- {ruby: 3.0, rails: 6 },
229
- {ruby: 3.0, rails: 5_2},
230
- {ruby: 2.7, rails: 5_2},
231
- {ruby: 2.5, rails: 7 },
232
- {ruby: jruby-9.2, rails: 7 },
233
- {ruby: jruby-9.3, rails: 7 },
234
- ]
235
- services:
236
- mysql:
237
- image: mysql:5.7
238
- env:
239
- MYSQL_ALLOW_EMPTY_PASSWORD: true
240
- MYSQL_USERNAME: root
241
- MYSQL_DATABASE: arelx_test
242
- ports:
243
- - 3306:3306
244
- options: >-
245
- --health-cmd="mysqladmin ping"
246
- --health-interval=10s
247
- --health-timeout=5s
248
- --health-retries=3
249
- steps:
250
- - uses: actions/checkout@v2
251
- - name: Set up Ruby
252
- uses: ruby/setup-ruby@v1
253
- with:
254
- ruby-version: ${{ matrix.ruby }}
255
- - name: Install FreeTDS
256
- run: |
257
- sudo apt-get update -q
258
- sudo apt-get install -y freetds-dev
259
- - name: Update system-wide gems
260
- run: gem update --system
261
- - name: Download gem from build job
262
- uses: actions/download-artifact@v2
263
- with:
264
- name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
265
- - name: Setup Gemfile
266
- if: ${{ matrix.rails != '5_2' }}
267
- run: |
268
- cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
269
- cp ./version_v2.rb lib/arel_extensions/version.rb
270
- cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
271
- - name: bundle install
272
- run: |
273
- bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
274
- bundle install
275
- - name: Run test MySql
276
- env:
277
- DB_CONNECTION: mysql
278
- DB_HOST: 127.0.0.1
279
- DB_PORT: 3306
280
- DB_DATABASE: arelx_test
281
- DB_USERNAME: root
282
- run: bundle exec rake test:mysql
283
-
284
- job_test_mssql:
285
- name: test mssql on linux
286
- needs: job_build_gem
287
- runs-on: ubuntu-latest
288
- strategy:
289
- fail-fast: false
290
- matrix:
291
- ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
292
- rails: [6_1, 6, 5_2]
293
- version: [2017, 2019]
294
- exclude: [
295
- {ruby: 3.1, rails: 6 },
296
- {ruby: 3.1, rails: 5_2 },
297
- {ruby: 3.0, rails: 6 },
298
- {ruby: 3.0, rails: 5_2 },
299
- {ruby: 2.7, rails: 5_2 },
300
- # {ruby: 2.5, rails: 7 },
301
- # {ruby: jruby-9.2, rails: 7 },
302
- {ruby: jruby-9.2, rails: 6_1 },
303
- {ruby: jruby-9.2, rails: 6 },
304
- # {ruby: jruby-9.3, rails: 7 },
305
- {ruby: jruby-9.3, rails: 6_1 },
306
- {ruby: jruby-9.3, rails: 6 },
307
- ]
308
- steps:
309
- - uses: actions/checkout@v2
310
- - name: Set up Ruby
311
- uses: ruby/setup-ruby@v1
312
- with:
313
- ruby-version: ${{ matrix.ruby }}
314
- - name: Install FreeTDS
315
- run: |
316
- sudo apt-get update -q
317
- sudo apt-get install -y freetds-dev
318
- - name: Install MSSQL ${{ matrix.version }}
319
- uses: potatoqualitee/mssqlsuite@v1.5.1
320
- with:
321
- version: ${{ matrix.version }}
322
- install: sqlengine, sqlclient, sqlpackage, localdb
323
- sa-password: Password12!
324
- - name: Update system-wide gems
325
- run: gem update --system
326
- - name: Download gem from build job
327
- uses: actions/download-artifact@v2
328
- with:
329
- name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
330
- - name: Setup Gemfile
331
- if: ${{ matrix.rails != '5_2' }}
332
- run: |
333
- cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
334
- cp ./version_v2.rb lib/arel_extensions/version.rb
335
- cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
336
- - name: bundle install
337
- run: |
338
- bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
339
- bundle install
340
- - name: Run test mssql
341
- run: bundle exec rake test:mssql
@@ -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]
12
- gem 'mysql2', '0.5.2', platforms: [:mri]
13
- gem 'pg', '< 1.0.0', platforms: [:mri]
14
-
15
- gem 'tiny_tds', platforms: %i[mri mingw x64_mingw mswin]
16
- gem 'activerecord-sqlserver-adapter', '~> 6.0', platforms: %i[mri mingw x64_mingw mswin]
17
- gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw]
18
-
19
- gem 'ruby-oci8', platforms: %i[mri mswin mingw] if ENV.has_key? 'ORACLE_HOME'
20
- gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0' if ENV.has_key? 'ORACLE_HOME'
21
-
22
- # for JRuby
23
- gem 'activerecord-jdbc-adapter', github: 'jruby/activerecord-jdbc-adapter', tag: 'v60.4', platforms: :jruby
24
- gem 'jdbc-sqlite3', platforms: :jruby
25
- gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
26
- gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
27
- gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
28
- end
29
-
30
- gemspec path: Dir.pwd
@@ -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]
12
- gem 'mysql2', '0.5.2', platforms: [:mri]
13
- gem 'pg', '~> 1.1', platforms: [:mri]
14
-
15
- gem 'tiny_tds', platforms: %i[mri mingw x64_mingw mswin]
16
- gem 'activerecord-sqlserver-adapter', '~> 6.1.0', platforms: %i[mri mingw x64_mingw mswin]
17
- gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw]
18
-
19
- gem 'ruby-oci8', platforms: %i[mri mswin mingw] if ENV.has_key? 'ORACLE_HOME'
20
- gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0' if ENV.has_key? 'ORACLE_HOME'
21
-
22
- # for JRuby
23
- gem 'activerecord-jdbc-adapter', github: 'jruby/activerecord-jdbc-adapter', tag: 'v61.1', platforms: :jruby
24
- gem 'jdbc-sqlite3', platforms: :jruby
25
- gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
26
- gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
27
- gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
28
- end
29
-
30
- gemspec path: Dir.pwd
@@ -1,23 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rails', '~> 7.0.1'
4
-
5
-
6
- group :development, :test do
7
- gem 'activesupport', '~> 7.0.1'
8
- gem 'activemodel', '~> 7.0.1'
9
- gem 'activerecord', '~> 7.0.1'
10
-
11
- gem 'sqlite3', '~> 1.4', platforms: [:mri]
12
- gem 'mysql2', '0.5.2', platforms: [:mri]
13
- gem 'pg', '~> 1.1', platforms: [:mri]
14
-
15
- gem 'tiny_tds', platforms: %i[mri mingw x64_mingw mswin]
16
- gem 'activerecord-sqlserver-adapter', '~> 7.0.0.0', platforms: %i[mri mingw x64_mingw mswin]
17
- gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw]
18
-
19
- gem 'ruby-oci8', platforms: %i[mri mswin mingw] if ENV.has_key? 'ORACLE_HOME'
20
- gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0' if ENV.has_key? 'ORACLE_HOME'
21
- end
22
-
23
- gemspec path: Dir.pwd
@@ -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', '>= 6.3.1')
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', '>= 6.3.1')
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,14 +0,0 @@
1
- module ArelExtensions
2
- module Aliases
3
-
4
- # Install an alias, if present.
5
- def xas other
6
- if other.present?
7
- Arel::Nodes::As.new(self, Arel.sql(other))
8
- else
9
- self
10
- end
11
- end
12
-
13
- end
14
- end
@@ -1,51 +0,0 @@
1
- module ArelExtensions
2
-
3
- #
4
- # column_of
5
- #
6
- # Before the creation of these methods, getting the column name was done
7
- # uniquely through the code found in `column_of_via_arel_table`.
8
- #
9
- # This turned out to be unreliable, most notably when using adapters that do
10
- # not come with activerecord standard batteries. SQL Server is the most
11
- # notorious example.
12
- #
13
- # Currently, we're using a needlessly complicated way to address this issue.
14
- # Different versions of activerecord are behaving differently; the public APIs
15
- # do not seem to come with any guarantees, so we need to be sure that we're
16
- # coveing all these cases.
17
-
18
- def self.column_of_via_arel_table(table_name, column_name)
19
- Arel::Table.engine.connection.schema_cache.columns_hash(table_name)[column_name]
20
- rescue NoMethodError
21
- nil
22
- rescue => e
23
- warn("Warning: Unexpected exception caught while fetching column name for #{table_name}.#{column_name} in `column_of_via_arel_table`\n#{e.class}: #{e}")
24
- nil
25
- end
26
-
27
- def self.column_of(table_name, column_name)
28
- pool = ActiveRecord::Base.connection.pool
29
- use_arel_table = !ActiveRecord::Base.connected? || \
30
- (pool.respond_to?(:schema_cache) && pool.schema_cache.nil?)
31
-
32
- if use_arel_table
33
- column_of_via_arel_table(table_name, column_name)
34
- else
35
- if pool.respond_to?(:pool_config)
36
- pool.pool_config.schema_cache.columns_hash(table_name)[column_name]
37
- elsif pool.respond_to?(:schema_cache)
38
- pool.schema_cache.columns_hash(table_name)[column_name]
39
- else
40
- column_of_via_arel_table(table_name, column_name)
41
- end
42
- end
43
- rescue ActiveRecord::ConnectionNotEstablished
44
- column_of_via_arel_table(table_name, column_name)
45
- rescue ActiveRecord::StatementInvalid
46
- nil
47
- rescue => e
48
- warn("Warning: Unexpected exception caught while fetching column name for #{table_name}.#{column_name} in `column_of`\n#{e.class}: #{e}")
49
- nil
50
- end
51
- end
@@ -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