arel_extensions 1.3.7 → 2.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) 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 -270
  14. data/Rakefile +30 -41
  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 -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 +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 -292
  89. data/lib/arel_extensions/visitors.rb +58 -82
  90. data/lib/arel_extensions.rb +31 -175
  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 -702
  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 -31
  108. data/.github/workflows/ruby.yml +0 -344
  109. data/NEWS.md +0 -32
  110. data/gemfiles/rails4_2.gemfile +0 -38
  111. data/gemfiles/rails5.gemfile +0 -29
  112. data/gemfiles/rails6.gemfile +0 -30
  113. data/gemfiles/rails6_1.gemfile +0 -30
  114. data/gemfiles/rails7.gemfile +0 -23
  115. data/gemspecs/arel_extensions-v1.gemspec +0 -27
  116. data/gemspecs/arel_extensions-v2.gemspec +0 -27
  117. data/generate_gems.sh +0 -15
  118. data/lib/arel_extensions/aliases.rb +0 -14
  119. data/lib/arel_extensions/helpers.rb +0 -51
  120. data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
  121. data/lib/arel_extensions/nodes/formatted_date.rb +0 -42
  122. data/lib/arel_extensions/nodes/rollup.rb +0 -36
  123. data/lib/arel_extensions/nodes/select.rb +0 -10
  124. data/lib/arel_extensions/nodes/sum.rb +0 -7
  125. data/lib/arel_extensions/visitors/convert_format.rb +0 -37
  126. data/test/arelx_test_helper.rb +0 -71
  127. data/version_v1.rb +0 -3
  128. data/version_v2.rb +0 -3
@@ -1,344 +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_test_to_sql:
10
- name: test to_sql
11
- runs-on: ubuntu-latest
12
- strategy:
13
- fail-fast: false
14
- matrix:
15
- versions: [
16
- {ruby: '3.2', rails: 7, arelx: 2},
17
- {ruby: '3.2', rails: 6_1, arelx: 2},
18
- {ruby: '3.1', rails: 7, arelx: 2},
19
- {ruby: '3.1', rails: 6_1, arelx: 2},
20
- {ruby: '3.0', rails: 7, arelx: 2},
21
- {ruby: '3.0', rails: 6_1, arelx: 2},
22
- {ruby: '2.7', rails: 7, arelx: 2},
23
- {ruby: '2.7', rails: 6_1, arelx: 2},
24
- {ruby: '2.7', rails: 6, arelx: 2},
25
- {ruby: '2.7', rails: 5_2, arelx: 1},
26
- {ruby: '2.7', rails: 4_2, arelx: 1},
27
- {ruby: '2.5', rails: 6_1, arelx: 2},
28
- {ruby: '2.5', rails: 6, arelx: 2},
29
- {ruby: '2.5', rails: 5_2, arelx: 1},
30
- {ruby: '2.5', rails: 4_2, arelx: 1},
31
- {ruby: jruby-9.2, rails: 6_1, arelx: 2},
32
- {ruby: jruby-9.2, rails: 6, arelx: 2},
33
- {ruby: jruby-9.2, rails: 5_2, arelx: 1},
34
- {ruby: jruby-9.3, rails: 6_1, arelx: 2},
35
- {ruby: jruby-9.3, rails: 6, arelx: 2},
36
- {ruby: jruby-9.3, rails: 5_2, arelx: 1},
37
- ]
38
- steps:
39
- - uses: actions/checkout@v2
40
- - name: Set up Ruby
41
- uses: ruby/setup-ruby@v1
42
- with:
43
- ruby-version: ${{ matrix.versions.ruby }}
44
- - name: Install FreeTDS
45
- run: |
46
- sudo apt-get update -q
47
- sudo apt-get install -y freetds-dev
48
- - name: Update system-wide gems
49
- if: ${{ !contains(fromJson('["2.5", "jruby-9.2"]'), matrix.versions.ruby) }}
50
- run: gem update --system --no-document
51
- - name: Setup Gemfile for arelx 2.x
52
- if: ${{ matrix.versions.arelx == 2 }}
53
- run: |
54
- cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
55
- cp ./version_v2.rb lib/arel_extensions/version.rb
56
- cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
57
- - name: bundle install
58
- run: |
59
- bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
60
- bundle install
61
- - name: Run test to_sql
62
- run: bundle exec rake test:to_sql
63
-
64
- job_test_sqlite:
65
- name: test sqlite
66
- runs-on: ubuntu-latest
67
- strategy:
68
- fail-fast: false
69
- matrix:
70
- versions: [
71
- {ruby: '3.2', rails: 7, arelx: 2},
72
- {ruby: '3.2', rails: 6_1, arelx: 2},
73
- {ruby: '3.1', rails: 7, arelx: 2},
74
- {ruby: '3.1', rails: 6_1, arelx: 2},
75
- {ruby: '3.0', rails: 7, arelx: 2},
76
- {ruby: '3.0', rails: 6_1, arelx: 2},
77
- {ruby: '2.7', rails: 7, arelx: 2},
78
- {ruby: '2.7', rails: 6_1, arelx: 2},
79
- {ruby: '2.7', rails: 6, arelx: 2},
80
- {ruby: '2.7', rails: 5_2, arelx: 1},
81
- {ruby: '2.7', rails: 4_2, arelx: 1},
82
- {ruby: '2.5', rails: 6_1, arelx: 2},
83
- {ruby: '2.5', rails: 6, arelx: 2},
84
- {ruby: '2.5', rails: 5_2, arelx: 1},
85
- {ruby: '2.5', rails: 4_2, arelx: 1},
86
- {ruby: jruby-9.2, rails: 6_1, arelx: 2},
87
- {ruby: jruby-9.2, rails: 6, arelx: 2},
88
- {ruby: jruby-9.2, rails: 5_2, arelx: 1},
89
- {ruby: jruby-9.2, rails: 4_2, arelx: 1},
90
- {ruby: jruby-9.3, rails: 6_1, arelx: 2},
91
- {ruby: jruby-9.3, rails: 6, arelx: 2},
92
- {ruby: jruby-9.3, rails: 5_2, arelx: 1},
93
- ]
94
- steps:
95
- - uses: actions/checkout@v2
96
- - name: Set up Ruby
97
- uses: ruby/setup-ruby@v1
98
- with:
99
- ruby-version: ${{ matrix.versions.ruby }}
100
- - name: Install FreeTDS
101
- run: |
102
- sudo apt-get update -q
103
- sudo apt-get install -y freetds-dev
104
- - name: Update system-wide gems
105
- if: ${{ !contains(fromJson('["2.5", "jruby-9.2"]'), matrix.versions.ruby) }}
106
- run: gem update --system --no-document
107
- - name: Setup Gemfile
108
- if: ${{ matrix.versions.arelx == 2 }}
109
- run: |
110
- cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
111
- cp ./version_v2.rb lib/arel_extensions/version.rb
112
- cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
113
- - name: bundle install
114
- run: |
115
- bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
116
- bundle install
117
- - name: Run test sqlite
118
- run: bundle exec rake test:sqlite
119
-
120
- job_test_postgres:
121
- name: test postgres
122
- runs-on: ubuntu-latest
123
- strategy:
124
- fail-fast: false
125
- matrix:
126
- versions: [
127
- {ruby: '3.2', rails: 7, arelx: 2},
128
- {ruby: '3.2', rails: 6_1, arelx: 2},
129
- {ruby: '3.1', rails: 7, arelx: 2},
130
- {ruby: '3.1', rails: 6_1, arelx: 2},
131
- {ruby: '3.0', rails: 7, arelx: 2},
132
- {ruby: '3.0', rails: 6_1, arelx: 2},
133
- {ruby: '2.7', rails: 7, arelx: 2},
134
- {ruby: '2.7', rails: 6_1, arelx: 2},
135
- {ruby: '2.7', rails: 6, arelx: 2},
136
- {ruby: '2.7', rails: 5_2, arelx: 1},
137
- {ruby: '2.7', rails: 4_2, arelx: 1},
138
- {ruby: '2.5', rails: 6_1, arelx: 2},
139
- {ruby: '2.5', rails: 6, arelx: 2},
140
- {ruby: '2.5', rails: 5_2, arelx: 1},
141
- {ruby: '2.5', rails: 4_2, arelx: 1},
142
- {ruby: jruby-9.2, rails: 6_1, arelx: 2},
143
- {ruby: jruby-9.2, rails: 6, arelx: 2},
144
- {ruby: jruby-9.2, rails: 5_2, arelx: 1},
145
- {ruby: jruby-9.2, rails: 4_2, arelx: 1},
146
- {ruby: jruby-9.3, rails: 6_1, arelx: 2},
147
- {ruby: jruby-9.3, rails: 6, arelx: 2},
148
- {ruby: jruby-9.3, rails: 5_2, arelx: 1},
149
- ]
150
- steps:
151
- - uses: actions/checkout@v2
152
- # PostgreSQL requires locales to be installed on the system to be able
153
- # to do time and currency conversions at runtime.
154
- #
155
- # That's why we're not launching it as a service; pre-built images
156
- # lack loaclization.
157
- #
158
- # After we install locales, we'll install PostgreSQL binaries and start
159
- # the service.
160
- - name: setup locale
161
- run: |
162
- sudo locale-gen fr_FR.utf8
163
- sudo update-locale
164
- - name: setup postgres 11
165
- run: |
166
- curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
167
- echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
168
- sudo apt update
169
- sudo apt -y install postgresql-11
170
- sudo systemctl enable postgresql
171
- sudo systemctl start postgresql
172
- sudo su -c "psql -c \"alter user postgres with password 'secret'\"" postgres
173
- sudo su -c "createdb arelx_test" postgres
174
- - name: Set up Ruby
175
- uses: ruby/setup-ruby@v1
176
- with:
177
- ruby-version: ${{ matrix.versions.ruby }}
178
- - name: Install FreeTDS
179
- run: |
180
- sudo apt-get update -q
181
- sudo apt-get install -y freetds-dev
182
- - name: Update system-wide gems
183
- if: ${{ !contains(fromJson('["2.5", "jruby-9.2"]'), matrix.versions.ruby) }}
184
- run: gem update --system --no-document
185
- - name: Setup Gemfile
186
- if: ${{ matrix.versions.arelx == 2 }}
187
- run: |
188
- cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
189
- cp ./version_v2.rb lib/arel_extensions/version.rb
190
- cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
191
- - name: bundle install
192
- run: |
193
- bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
194
- bundle install
195
- - name: Run test Postgres
196
- env:
197
- PGHOST: localhost
198
- PGUSER: postgres
199
- run: bundle exec rake test:postgresql
200
-
201
- job_test_mysql:
202
- name: test mysql
203
- runs-on: ubuntu-latest
204
- strategy:
205
- fail-fast: false
206
- matrix:
207
- versions: [
208
- {ruby: '3.2', rails: 7, arelx: 2},
209
- {ruby: '3.2', rails: 6_1, arelx: 2},
210
- {ruby: '3.1', rails: 7, arelx: 2},
211
- {ruby: '3.1', rails: 6_1, arelx: 2},
212
- {ruby: '3.0', rails: 7, arelx: 2},
213
- {ruby: '3.0', rails: 6_1, arelx: 2},
214
- {ruby: '2.7', rails: 7, arelx: 2},
215
- {ruby: '2.7', rails: 6_1, arelx: 2},
216
- {ruby: '2.7', rails: 6, arelx: 2},
217
- {ruby: '2.7', rails: 5_2, arelx: 1},
218
- {ruby: '2.7', rails: 4_2, arelx: 1},
219
- {ruby: '2.5', rails: 6_1, arelx: 2},
220
- {ruby: '2.5', rails: 6, arelx: 2},
221
- {ruby: '2.5', rails: 5_2, arelx: 1},
222
- {ruby: '2.5', rails: 4_2, arelx: 1},
223
- {ruby: jruby-9.2, rails: 6_1, arelx: 2},
224
- {ruby: jruby-9.2, rails: 6, arelx: 2},
225
- {ruby: jruby-9.2, rails: 5_2, arelx: 1},
226
- {ruby: jruby-9.2, rails: 4_2, arelx: 1},
227
- {ruby: jruby-9.3, rails: 6_1, arelx: 2},
228
- {ruby: jruby-9.3, rails: 6, arelx: 2},
229
- {ruby: jruby-9.3, rails: 5_2, arelx: 1},
230
- ]
231
- services:
232
- mysql:
233
- image: mysql:5.7
234
- env:
235
- MYSQL_ALLOW_EMPTY_PASSWORD: true
236
- MYSQL_USERNAME: root
237
- MYSQL_DATABASE: arelx_test
238
- ports:
239
- - 3306:3306
240
- options: >-
241
- --health-cmd="mysqladmin ping"
242
- --health-interval=10s
243
- --health-timeout=5s
244
- --health-retries=3
245
- steps:
246
- - uses: actions/checkout@v2
247
- - name: Set up Ruby
248
- uses: ruby/setup-ruby@v1
249
- with:
250
- ruby-version: ${{ matrix.versions.ruby }}
251
- - name: Install FreeTDS
252
- run: |
253
- sudo apt-get update -q
254
- sudo apt-get install -y freetds-dev
255
- - name: Update system-wide gems
256
- if: ${{ !contains(fromJson('["2.5", "jruby-9.2"]'), matrix.versions.ruby) }}
257
- run: gem update --system --no-document
258
- - name: Setup Gemfile
259
- if: ${{ matrix.versions.arelx == 2 }}
260
- run: |
261
- cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
262
- cp ./version_v2.rb lib/arel_extensions/version.rb
263
- cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
264
- - name: bundle install
265
- run: |
266
- bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
267
- bundle install
268
- - name: Run test MySql
269
- env:
270
- DB_CONNECTION: mysql
271
- DB_HOST: 127.0.0.1
272
- DB_PORT: 3306
273
- DB_DATABASE: arelx_test
274
- DB_USERNAME: root
275
- run: bundle exec rake test:mysql
276
-
277
- job_test_mssql:
278
- name: test mssql on linux
279
- runs-on: ubuntu-latest
280
- strategy:
281
- fail-fast: false
282
- matrix:
283
- versions: [
284
- # {ruby: '3.2', rails: 7, arelx: 2},
285
- {ruby: '3.2', rails: 6_1, arelx: 2},
286
- # {ruby: '3.1', rails: 7, arelx: 2},
287
- {ruby: '3.1', rails: 6_1, arelx: 2},
288
- # {ruby: '3.0', rails: 7, arelx: 2},
289
- {ruby: '3.0', rails: 6_1, arelx: 2},
290
- # {ruby: '2.7', rails: 7, arelx: 2},
291
- {ruby: '2.7', rails: 6_1, arelx: 2},
292
- {ruby: '2.7', rails: 6, arelx: 2},
293
- {ruby: '2.7', rails: 5_2, arelx: 1},
294
- {ruby: '2.7', rails: 4_2, arelx: 1},
295
- {ruby: '2.5', rails: 6_1, arelx: 2},
296
- {ruby: '2.5', rails: 6, arelx: 2},
297
- {ruby: '2.5', rails: 5_2, arelx: 1},
298
- {ruby: '2.5', rails: 4_2, arelx: 1},
299
- # {ruby: jruby-9.2, rails: 6_1, arelx: 2},
300
- # {ruby: jruby-9.2, rails: 6, arelx: 2},
301
- {ruby: jruby-9.2, rails: 5_2, arelx: 1},
302
- {ruby: jruby-9.2, rails: 4_2, arelx: 1},
303
- # {ruby: jruby-9.3, rails: 6_1, arelx: 2},
304
- # {ruby: jruby-9.3, rails: 6, arelx: 2},
305
- {ruby: jruby-9.3, rails: 5_2, arelx: 1},
306
- ]
307
- mssql: [2017, 2019]
308
- steps:
309
- - uses: actions/checkout@v2
310
- - name: Set up Ruby
311
- uses: ruby/setup-ruby@v1
312
- with:
313
- ruby-version: ${{ matrix.versions.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.mssql }}
319
- uses: potatoqualitee/mssqlsuite@v1.5.1
320
- with:
321
- version: ${{ matrix.mssql }}
322
- install: sqlengine, sqlclient, sqlpackage, localdb
323
- sa-password: Password12!
324
- - name: Update system-wide gems
325
- if: ${{ !contains(fromJson('["2.5", "jruby-9.2"]'), matrix.versions.ruby) }}
326
- run: gem update --system --no-document
327
- - name: Setup Gemfile
328
- if: ${{ matrix.versions.arelx == 2 }}
329
- run: |
330
- cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
331
- cp ./version_v2.rb lib/arel_extensions/version.rb
332
- cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
333
- - name: bundle install
334
- run: |
335
- bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
336
- bundle install
337
- - name: Run test mssql [mri]
338
- if: ${{ !contains(matrix.versions.ruby, 'jruby') }}
339
- run: bundle exec rake test:mssql
340
- - name: Run test mssql [jruby]
341
- if: ${{ contains(matrix.versions.ruby, 'jruby') }}
342
- run: |
343
- curl -LO https://github.com/microsoft/mssql-jdbc/releases/download/v8.4.1/mssql-jdbc-8.4.1.jre11.jar
344
- CLASSPATH=".:mssql-jdbc-8.4.1.jre11.jar" bundle exec rake test:mssql
data/NEWS.md DELETED
@@ -1,32 +0,0 @@
1
- # News
2
-
3
- ## Current Release
4
-
5
- ### New Features
6
-
7
- - `o.format_date` as an alternative to `o.format`
8
- The actual behavior of `format` is inconsistent across DB vendors: in mysql we
9
- can format dates and numbers with it, and in the other ones we only format
10
- dates.
11
-
12
- We're planning on normalizing this behavior. We want `format` to "cleverly"
13
- format dates or numbers, and `format_date` / `format_number` to strictly
14
- format dates / numbers.
15
-
16
- The introduction of `format_date` is the first step in this direction.
17
-
18
- ## Release v2.1.6/v1.3.6
19
-
20
- ### Bug Fixes
21
-
22
- - This used to fail.
23
- ```
24
- Arel.when(a).then(b).format('%Y-%m-%d')
25
- ```
26
-
27
- ### New Features
28
-
29
- - `o.present`, a synonym for `o.not_blank`
30
- - `o.coalesce_blank(a, b, c)`
31
- - `o.if_present`, if the value is `null` or blank, then it returns `null`,
32
- otherwise, it returns the value. Inspired by rails' `presence`.
@@ -1,38 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'arel', '~> 6.0'
4
-
5
- group :development, :test do
6
- # We need to explicitly include bigdecimal for ruby 2.7 .
7
- # See https://github.com/ruby/bigdecimal for details.
8
- rb_version = Gem::Version.new(RUBY_VERSION)
9
- if Gem::Version.new('2.7') <= rb_version && rb_version < Gem::Version.new('2.8')
10
- gem 'bigdecimal', '~> 1.3.5', platforms: %i[mri mingw x64_mingw mswin]
11
- end
12
-
13
- gem 'activesupport', '~> 4.0'
14
- gem 'activemodel', '~> 4.0'
15
- gem 'activerecord', '~> 4.0'
16
-
17
- gem 'sqlite3', '<= 1.3.13', platforms: %i[mri mswin mingw]
18
- gem 'mysql2', '0.4.10', platforms: %i[mri mswin mingw]
19
- gem 'pg', '< 1.0.0', platforms: %i[mri mingw]
20
-
21
- gem 'tiny_tds', platforms: %i[mri mingw x64_mingw mswin]
22
- gem 'activerecord-sqlserver-adapter', '~> 4.2.0', platforms: %i[mri mingw x64_mingw mswin]
23
-
24
- gem 'ruby-oci8', platforms: %i[mri mswin mingw] if ENV.has_key? 'ORACLE_HOME'
25
- gem 'activerecord-oracle_enhanced-adapter', '~> 1.6.0' if ENV.has_key? 'ORACLE_HOME'
26
-
27
- # for JRuby
28
- gem 'activerecord-jdbc-adapter', '~> 1.3', platforms: :jruby
29
- gem 'jdbc-sqlite3', '~> 3.28', platforms: :jruby
30
- gem 'jdbc-postgres', '~> 42.2', platforms: :jruby
31
- gem 'jdbc-mysql', '~> 5.1', platforms: :jruby
32
- gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
33
- gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
34
- gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
35
- gem 'activerecord-jdbcmssql-adapter', platforms: :jruby
36
- end
37
-
38
- gemspec path: Dir.pwd
@@ -1,29 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'arel', '~> 7.0'
4
-
5
- group :development, :test do
6
- gem 'activesupport', '~> 5.0'
7
- gem 'activemodel', '~> 5.0'
8
- gem 'activerecord', '5.0.6'
9
-
10
- gem 'sqlite3', '<= 1.3.13', platforms: %i[mri mswin mingw]
11
- gem 'mysql2', '0.4.10', platforms: %i[mri mswin mingw]
12
- gem 'pg', '< 1.0.0', platforms: %i[mri mingw]
13
-
14
- gem 'tiny_tds', platforms: %i[mri mingw] if RUBY_PLATFORM.match?(/windows/)
15
- # gem "activerecord-sqlserver-adapter", platforms: [:mri, :mingw]
16
-
17
- gem 'ruby-oci8', platforms: %i[mri mswin mingw] if ENV.has_key? 'ORACLE_HOME'
18
- gem 'activerecord-oracle_enhanced-adapter', '~> 1.7' if ENV.has_key? 'ORACLE_HOME'
19
-
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
27
- end
28
-
29
- gemspec path: Dir.pwd
@@ -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', 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', 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,27 +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('rake', '~> 12.3.3')
27
- end
@@ -1,27 +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('rake', '~> 12.3.3')
27
- 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