arel_extensions 2.1.4 → 2.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +162 -222
  3. data/.gitignore +7 -6
  4. data/.rubocop.yml +37 -0
  5. data/Gemfile +3 -3
  6. data/NEWS.md +15 -0
  7. data/README.md +119 -75
  8. data/appveyor.yml +82 -0
  9. data/arel_extensions.gemspec +0 -1
  10. data/gemfiles/rails3.gemfile +5 -5
  11. data/gemfiles/rails4_2.gemfile +38 -0
  12. data/gemfiles/{rails5_0.gemfile → rails5.gemfile} +6 -6
  13. data/gemfiles/rails5_1_4.gemfile +6 -6
  14. data/gemfiles/rails5_2.gemfile +6 -5
  15. data/gemfiles/rails6.gemfile +5 -4
  16. data/gemfiles/rails6_1.gemfile +5 -4
  17. data/gemfiles/rails7.gemfile +5 -4
  18. data/gemspecs/arel_extensions-v1.gemspec +0 -1
  19. data/gemspecs/arel_extensions-v2.gemspec +0 -1
  20. data/lib/arel_extensions/common_sql_functions.rb +2 -2
  21. data/lib/arel_extensions/helpers.rb +12 -12
  22. data/lib/arel_extensions/math.rb +32 -17
  23. data/lib/arel_extensions/nodes/case.rb +4 -3
  24. data/lib/arel_extensions/nodes/cast.rb +2 -2
  25. data/lib/arel_extensions/nodes/coalesce.rb +1 -1
  26. data/lib/arel_extensions/nodes/collate.rb +1 -1
  27. data/lib/arel_extensions/nodes/date_diff.rb +6 -6
  28. data/lib/arel_extensions/nodes/locate.rb +1 -1
  29. data/lib/arel_extensions/nodes/repeat.rb +2 -2
  30. data/lib/arel_extensions/nodes/rollup.rb +36 -0
  31. data/lib/arel_extensions/nodes/select.rb +10 -0
  32. data/lib/arel_extensions/nodes/substring.rb +1 -1
  33. data/lib/arel_extensions/nodes/then.rb +1 -1
  34. data/lib/arel_extensions/nodes/trim.rb +2 -2
  35. data/lib/arel_extensions/nodes/union.rb +3 -3
  36. data/lib/arel_extensions/nodes/union_all.rb +2 -2
  37. data/lib/arel_extensions/null_functions.rb +16 -0
  38. data/lib/arel_extensions/string_functions.rb +1 -0
  39. data/lib/arel_extensions/version.rb +1 -1
  40. data/lib/arel_extensions/visitors/ibm_db.rb +1 -1
  41. data/lib/arel_extensions/visitors/mssql.rb +123 -17
  42. data/lib/arel_extensions/visitors/mysql.rb +78 -11
  43. data/lib/arel_extensions/visitors/oracle.rb +39 -17
  44. data/lib/arel_extensions/visitors/postgresql.rb +17 -12
  45. data/lib/arel_extensions/visitors/sqlite.rb +4 -4
  46. data/lib/arel_extensions/visitors/to_sql.rb +4 -1
  47. data/lib/arel_extensions/visitors.rb +8 -0
  48. data/lib/arel_extensions.rb +26 -0
  49. data/test/arelx_test_helper.rb +1 -1
  50. data/test/real_db_test.rb +5 -5
  51. data/test/support/fake_record.rb +1 -1
  52. data/test/visitors/test_bulk_insert_oracle.rb +3 -3
  53. data/test/visitors/test_bulk_insert_sqlite.rb +1 -1
  54. data/test/visitors/test_bulk_insert_to_sql.rb +1 -1
  55. data/test/visitors/test_to_sql.rb +6 -6
  56. data/test/with_ar/all_agnostic_test.rb +177 -70
  57. data/test/with_ar/insert_agnostic_test.rb +3 -3
  58. data/test/with_ar/test_bulk_sqlite.rb +1 -1
  59. data/version_v1.rb +1 -1
  60. data/version_v2.rb +1 -1
  61. metadata +8 -18
  62. data/gemfiles/rails4.gemfile +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 292fe79fad9ac5f56c0ab194cdd8335eb632b6a97144138423dfe7f99b528dd3
4
- data.tar.gz: 7924daff5fb2c08ed2f6c63ef99629aa43ce90ca310d175618f279f61b5ae85c
3
+ metadata.gz: 8c31abd9b0c4ea7cfe26860fba2149ba9a998340e5a34e782a4e0f6790f466fb
4
+ data.tar.gz: 045325b9361956a6f07f24b252aa2328dada7bb9a3ffd5b75cb59bb8d65fbdbb
5
5
  SHA512:
6
- metadata.gz: bb981aed1c1d97a9584d000f75e9b446afbf65947ce95cd21af5e0ba85182994e55c3f6fc6b49e09897940d09714e89502585cfa844487d5ac64787c7ed6810b
7
- data.tar.gz: 7816248c6ce60af5a5a24a5015b9d73f568d447806e7778b5adcc2570d5ebd344834fdd71db4d5c83c93fef727a3e1f8a6d02de81e75539547263a751c768a04
6
+ metadata.gz: 8988d1d77e9213dd6fbf36921604dd684d5ff624862a1be8c200cbd6c77233e9ae1130642eb711e92804862eefcc386c204dee765e541ca5290bf7d0ce5afabb
7
+ data.tar.gz: 918c39d67c2f3b1a1f9335818858d503072e34cda34d4112bac482c36d715258570a0a46c7b1a802893f57a9245af385e3a4f8c819548d2c716a02e9fe28032e
@@ -6,197 +6,182 @@ name: Build and Test
6
6
  on: [push, pull_request]
7
7
 
8
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
9
  job_test_to_sql:
47
10
  name: test to_sql
48
- needs: job_build_gem
49
11
  runs-on: ubuntu-latest
50
12
  strategy:
51
13
  fail-fast: false
52
14
  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},
15
+ versions: [
16
+ {ruby: 3.1, rails: 7, arelx: 2},
17
+ {ruby: 3.1, rails: 6_1, arelx: 2},
18
+ {ruby: 3.0, rails: 7, arelx: 2},
19
+ {ruby: 3.0, rails: 6_1, arelx: 2},
20
+ {ruby: 2.7, rails: 7, arelx: 2},
21
+ {ruby: 2.7, rails: 6_1, arelx: 2},
22
+ {ruby: 2.7, rails: 6, arelx: 2},
23
+ {ruby: 2.7, rails: 5_2, arelx: 1},
24
+ {ruby: 2.7, rails: 4_2, arelx: 1},
25
+ {ruby: 2.5, rails: 6_1, arelx: 2},
26
+ {ruby: 2.5, rails: 6, arelx: 2},
27
+ {ruby: 2.5, rails: 5_2, arelx: 1},
28
+ {ruby: 2.5, rails: 4_2, arelx: 1},
29
+ {ruby: jruby-9.2, rails: 6_1, arelx: 2},
30
+ {ruby: jruby-9.2, rails: 6, arelx: 2},
31
+ {ruby: jruby-9.2, rails: 5_2, arelx: 1},
32
+ {ruby: jruby-9.3, rails: 6_1, arelx: 2},
33
+ {ruby: jruby-9.3, rails: 6, arelx: 2},
34
+ {ruby: jruby-9.3, rails: 5_2, arelx: 1},
64
35
  ]
65
36
  steps:
66
37
  - uses: actions/checkout@v2
67
38
  - name: Set up Ruby
68
39
  uses: ruby/setup-ruby@v1
69
40
  with:
70
- ruby-version: ${{ matrix.ruby }}
41
+ ruby-version: ${{ matrix.versions.ruby }}
71
42
  - name: Install FreeTDS
72
43
  run: |
73
44
  sudo apt-get update -q
74
45
  sudo apt-get install -y freetds-dev
75
46
  - 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' }}
47
+ run: gem update --system --no-document
48
+ - name: Setup Gemfile for arelx 2.x
49
+ if: ${{ matrix.versions.arelx == 2 }}
83
50
  run: |
84
51
  cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
85
52
  cp ./version_v2.rb lib/arel_extensions/version.rb
86
- cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
53
+ cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
87
54
  - name: bundle install
88
55
  run: |
89
- bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
56
+ bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
90
57
  bundle install
91
58
  - name: Run test to_sql
92
59
  run: bundle exec rake test:to_sql
93
60
 
94
61
  job_test_sqlite:
95
62
  name: test sqlite
96
- needs: job_build_gem
97
63
  runs-on: ubuntu-latest
98
64
  strategy:
99
65
  fail-fast: false
100
66
  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},
67
+ versions: [
68
+ {ruby: 3.1, rails: 7, arelx: 2},
69
+ {ruby: 3.1, rails: 6_1, arelx: 2},
70
+ {ruby: 3.0, rails: 7, arelx: 2},
71
+ {ruby: 3.0, rails: 6_1, arelx: 2},
72
+ {ruby: 2.7, rails: 7, arelx: 2},
73
+ {ruby: 2.7, rails: 6_1, arelx: 2},
74
+ {ruby: 2.7, rails: 6, arelx: 2},
75
+ {ruby: 2.7, rails: 5_2, arelx: 1},
76
+ {ruby: 2.7, rails: 4_2, arelx: 1},
77
+ {ruby: 2.5, rails: 6_1, arelx: 2},
78
+ {ruby: 2.5, rails: 6, arelx: 2},
79
+ {ruby: 2.5, rails: 5_2, arelx: 1},
80
+ {ruby: 2.5, rails: 4_2, arelx: 1},
81
+ {ruby: jruby-9.2, rails: 6_1, arelx: 2},
82
+ {ruby: jruby-9.2, rails: 6, arelx: 2},
83
+ {ruby: jruby-9.2, rails: 5_2, arelx: 1},
84
+ {ruby: jruby-9.2, rails: 4_2, arelx: 1},
85
+ {ruby: jruby-9.3, rails: 6_1, arelx: 2},
86
+ {ruby: jruby-9.3, rails: 6, arelx: 2},
87
+ {ruby: jruby-9.3, rails: 5_2, arelx: 1},
112
88
  ]
113
89
  steps:
114
90
  - uses: actions/checkout@v2
115
91
  - name: Set up Ruby
116
92
  uses: ruby/setup-ruby@v1
117
93
  with:
118
- ruby-version: ${{ matrix.ruby }}
94
+ ruby-version: ${{ matrix.versions.ruby }}
119
95
  - name: Install FreeTDS
120
96
  run: |
121
97
  sudo apt-get update -q
122
98
  sudo apt-get install -y freetds-dev
123
99
  - 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
100
+ run: gem update --system --no-document
129
101
  - name: Setup Gemfile
130
- if: ${{ matrix.rails != '5_2' }}
102
+ if: ${{ matrix.versions.arelx == 2 }}
131
103
  run: |
132
104
  cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
133
105
  cp ./version_v2.rb lib/arel_extensions/version.rb
134
- cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
106
+ cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
135
107
  - name: bundle install
136
108
  run: |
137
- bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
109
+ bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
138
110
  bundle install
139
111
  - name: Run test sqlite
140
112
  run: bundle exec rake test:sqlite
141
113
 
142
114
  job_test_postgres:
143
115
  name: test postgres
144
- needs: job_build_gem
145
116
  runs-on: ubuntu-latest
146
117
  strategy:
147
118
  fail-fast: false
148
119
  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
- {ruby: 3.1, rails: 6 },
153
- {ruby: 3.1, rails: 5_2},
154
- {ruby: 3.0, rails: 6 },
155
- {ruby: 3.0, rails: 5_2},
156
- {ruby: 2.7, rails: 5_2},
157
- {ruby: 2.5, rails: 7 },
158
- {ruby: jruby-9.2, rails: 7},
159
- {ruby: jruby-9.3, rails: 7},
120
+ versions: [
121
+ {ruby: 3.1, rails: 7, arelx: 2},
122
+ {ruby: 3.1, rails: 6_1, arelx: 2},
123
+ {ruby: 3.0, rails: 7, arelx: 2},
124
+ {ruby: 3.0, rails: 6_1, arelx: 2},
125
+ {ruby: 2.7, rails: 7, arelx: 2},
126
+ {ruby: 2.7, rails: 6_1, arelx: 2},
127
+ {ruby: 2.7, rails: 6, arelx: 2},
128
+ {ruby: 2.7, rails: 5_2, arelx: 1},
129
+ {ruby: 2.7, rails: 4_2, arelx: 1},
130
+ {ruby: 2.5, rails: 6_1, arelx: 2},
131
+ {ruby: 2.5, rails: 6, arelx: 2},
132
+ {ruby: 2.5, rails: 5_2, arelx: 1},
133
+ {ruby: 2.5, rails: 4_2, arelx: 1},
134
+ {ruby: jruby-9.2, rails: 6_1, arelx: 2},
135
+ {ruby: jruby-9.2, rails: 6, arelx: 2},
136
+ {ruby: jruby-9.2, rails: 5_2, arelx: 1},
137
+ {ruby: jruby-9.2, rails: 4_2, arelx: 1},
138
+ {ruby: jruby-9.3, rails: 6_1, arelx: 2},
139
+ {ruby: jruby-9.3, rails: 6, arelx: 2},
140
+ {ruby: jruby-9.3, rails: 5_2, arelx: 1},
160
141
  ]
161
- services:
162
- postgres:
163
- image: postgres:11.6-alpine
164
- env:
165
- POSTGRES_DB: arelx_test
166
- POSTGRES_PASSWORD: secret
167
- ports:
168
- - 5432:5432
169
- # needed because the postgres container does not provide a healthcheck
170
- options: >-
171
- --health-cmd "pg_isready -d arelx_test -U postgres -p 5432"
172
- --health-interval 10s
173
- --health-timeout 5s
174
- --health-retries 5
175
142
  steps:
176
143
  - uses: actions/checkout@v2
144
+ # PostgreSQL requires locales to be installed on the system to be able
145
+ # to do time and currency conversions at runtime.
146
+ #
147
+ # That's why we're not launching it as a service; pre-built images
148
+ # lack loaclization.
149
+ #
150
+ # After we install locales, we'll install PostgreSQL binaries and start
151
+ # the service.
152
+ - name: setup locale
153
+ run: |
154
+ sudo locale-gen fr_FR.utf8
155
+ sudo update-locale
156
+ - name: setup postgres 11
157
+ run: |
158
+ curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
159
+ echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
160
+ sudo apt update
161
+ sudo apt -y install postgresql-11
162
+ sudo systemctl enable postgresql
163
+ sudo systemctl start postgresql
164
+ sudo su -c "psql -c \"alter user postgres with password 'secret'\"" postgres
165
+ sudo su -c "createdb arelx_test" postgres
177
166
  - name: Set up Ruby
178
167
  uses: ruby/setup-ruby@v1
179
168
  with:
180
- ruby-version: ${{ matrix.ruby }}
169
+ ruby-version: ${{ matrix.versions.ruby }}
181
170
  - name: Install FreeTDS
182
171
  run: |
183
172
  sudo apt-get update -q
184
173
  sudo apt-get install -y freetds-dev
185
174
  - name: Update system-wide gems
186
- run: gem update --system
187
- - name: Download gem from build job
188
- uses: actions/download-artifact@v2
189
- with:
190
- name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
175
+ run: gem update --system --no-document
191
176
  - name: Setup Gemfile
192
- if: ${{ matrix.rails != '5_2' }}
177
+ if: ${{ matrix.versions.arelx == 2 }}
193
178
  run: |
194
179
  cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
195
180
  cp ./version_v2.rb lib/arel_extensions/version.rb
196
- cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
181
+ cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
197
182
  - name: bundle install
198
183
  run: |
199
- bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
184
+ bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
200
185
  bundle install
201
186
  - name: Run test Postgres
202
187
  env:
@@ -206,22 +191,31 @@ jobs:
206
191
 
207
192
  job_test_mysql:
208
193
  name: test mysql
209
- needs: job_build_gem
210
194
  runs-on: ubuntu-latest
211
195
  strategy:
212
196
  fail-fast: false
213
197
  matrix:
214
- ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
215
- rails: [7, 6_1, 6, 5_2]
216
- exclude: [
217
- {ruby: 3.1, rails: 6 },
218
- {ruby: 3.1, rails: 5_2},
219
- {ruby: 3.0, rails: 6 },
220
- {ruby: 3.0, rails: 5_2},
221
- {ruby: 2.7, rails: 5_2},
222
- {ruby: 2.5, rails: 7 },
223
- {ruby: jruby-9.2, rails: 7 },
224
- {ruby: jruby-9.3, rails: 7 },
198
+ versions: [
199
+ {ruby: 3.1, rails: 7, arelx: 2},
200
+ {ruby: 3.1, rails: 6_1, arelx: 2},
201
+ {ruby: 3.0, rails: 7, arelx: 2},
202
+ {ruby: 3.0, rails: 6_1, arelx: 2},
203
+ {ruby: 2.7, rails: 7, arelx: 2},
204
+ {ruby: 2.7, rails: 6_1, arelx: 2},
205
+ {ruby: 2.7, rails: 6, arelx: 2},
206
+ {ruby: 2.7, rails: 5_2, arelx: 1},
207
+ {ruby: 2.7, rails: 4_2, arelx: 1},
208
+ {ruby: 2.5, rails: 6_1, arelx: 2},
209
+ {ruby: 2.5, rails: 6, arelx: 2},
210
+ {ruby: 2.5, rails: 5_2, arelx: 1},
211
+ {ruby: 2.5, rails: 4_2, arelx: 1},
212
+ {ruby: jruby-9.2, rails: 6_1, arelx: 2},
213
+ {ruby: jruby-9.2, rails: 6, arelx: 2},
214
+ {ruby: jruby-9.2, rails: 5_2, arelx: 1},
215
+ {ruby: jruby-9.2, rails: 4_2, arelx: 1},
216
+ {ruby: jruby-9.3, rails: 6_1, arelx: 2},
217
+ {ruby: jruby-9.3, rails: 6, arelx: 2},
218
+ {ruby: jruby-9.3, rails: 5_2, arelx: 1},
225
219
  ]
226
220
  services:
227
221
  mysql:
@@ -242,26 +236,22 @@ jobs:
242
236
  - name: Set up Ruby
243
237
  uses: ruby/setup-ruby@v1
244
238
  with:
245
- ruby-version: ${{ matrix.ruby }}
239
+ ruby-version: ${{ matrix.versions.ruby }}
246
240
  - name: Install FreeTDS
247
241
  run: |
248
242
  sudo apt-get update -q
249
243
  sudo apt-get install -y freetds-dev
250
244
  - name: Update system-wide gems
251
- run: gem update --system
252
- - name: Download gem from build job
253
- uses: actions/download-artifact@v2
254
- with:
255
- name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
245
+ run: gem update --system --no-document
256
246
  - name: Setup Gemfile
257
- if: ${{ matrix.rails != '5_2' }}
247
+ if: ${{ matrix.versions.arelx == 2 }}
258
248
  run: |
259
249
  cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
260
250
  cp ./version_v2.rb lib/arel_extensions/version.rb
261
- cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
251
+ cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
262
252
  - name: bundle install
263
253
  run: |
264
- bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
254
+ bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
265
255
  bundle install
266
256
  - name: Run test MySql
267
257
  env:
@@ -274,116 +264,66 @@ jobs:
274
264
 
275
265
  job_test_mssql:
276
266
  name: test mssql on linux
277
- needs: job_build_gem
278
267
  runs-on: ubuntu-latest
279
268
  strategy:
280
269
  fail-fast: false
281
270
  matrix:
282
- ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
283
- rails: [7, 6_1, 6, 5_2]
284
- exclude: [
285
- {ruby: 3.1, rails: 6 },
286
- {ruby: 3.1, rails: 5_2 },
287
- {ruby: 3.0, rails: 6 },
288
- {ruby: 3.0, rails: 5_2 },
289
- {ruby: 2.7, rails: 5_2 },
290
- {ruby: 2.5, rails: 7 },
291
- {ruby: jruby-9.2, rails: 7 },
292
- {ruby: jruby-9.2, rails: 6_1 },
293
- {ruby: jruby-9.2, rails: 6 },
294
- {ruby: jruby-9.3, rails: 7 },
295
- {ruby: jruby-9.3, rails: 6_1 },
296
- {ruby: jruby-9.3, rails: 6 },
271
+ versions: [
272
+ # {ruby: 3.1, rails: 7, arelx: 2},
273
+ {ruby: 3.1, rails: 6_1, arelx: 2},
274
+ # {ruby: 3.0, rails: 7, arelx: 2},
275
+ {ruby: 3.0, rails: 6_1, arelx: 2},
276
+ # {ruby: 2.7, rails: 7, arelx: 2},
277
+ {ruby: 2.7, rails: 6_1, arelx: 2},
278
+ {ruby: 2.7, rails: 6, arelx: 2},
279
+ {ruby: 2.7, rails: 5_2, arelx: 1},
280
+ {ruby: 2.7, rails: 4_2, arelx: 1},
281
+ {ruby: 2.5, rails: 6_1, arelx: 2},
282
+ {ruby: 2.5, rails: 6, arelx: 2},
283
+ {ruby: 2.5, rails: 5_2, arelx: 1},
284
+ {ruby: 2.5, rails: 4_2, arelx: 1},
285
+ # {ruby: jruby-9.2, rails: 6_1, arelx: 2},
286
+ # {ruby: jruby-9.2, rails: 6, arelx: 2},
287
+ {ruby: jruby-9.2, rails: 5_2, arelx: 1},
288
+ {ruby: jruby-9.2, rails: 4_2, arelx: 1},
289
+ # {ruby: jruby-9.3, rails: 6_1, arelx: 2},
290
+ # {ruby: jruby-9.3, rails: 6, arelx: 2},
291
+ {ruby: jruby-9.3, rails: 5_2, arelx: 1},
297
292
  ]
293
+ mssql: [2017, 2019]
298
294
  steps:
299
295
  - uses: actions/checkout@v2
300
296
  - name: Set up Ruby
301
297
  uses: ruby/setup-ruby@v1
302
298
  with:
303
- ruby-version: ${{ matrix.ruby }}
299
+ ruby-version: ${{ matrix.versions.ruby }}
304
300
  - name: Install FreeTDS
305
301
  run: |
306
302
  sudo apt-get update -q
307
303
  sudo apt-get install -y freetds-dev
308
- - name: Install MSSQL 2019
309
- uses: potatoqualitee/mssqlsuite@v1
304
+ - name: Install MSSQL ${{ matrix.mssql }}
305
+ uses: potatoqualitee/mssqlsuite@v1.5.1
310
306
  with:
307
+ version: ${{ matrix.mssql }}
311
308
  install: sqlengine, sqlclient, sqlpackage, localdb
312
309
  sa-password: Password12!
313
310
  - name: Update system-wide gems
314
- run: gem update --system
315
- - name: Download gem from build job
316
- uses: actions/download-artifact@v2
317
- with:
318
- name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
311
+ run: gem update --system --no-document
319
312
  - name: Setup Gemfile
320
- if: ${{ matrix.rails != '5_2' }}
313
+ if: ${{ matrix.versions.arelx == 2 }}
321
314
  run: |
322
315
  cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
323
316
  cp ./version_v2.rb lib/arel_extensions/version.rb
324
- cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
317
+ cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
325
318
  - name: bundle install
326
319
  run: |
327
- bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
320
+ bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
328
321
  bundle install
329
- - name: Run test mssql
322
+ - name: Run test mssql [mri]
323
+ if: ${{ !contains(matrix.versions.ruby, 'jruby') }}
330
324
  run: bundle exec rake test:mssql
331
-
332
- job_test_windows:
333
- name: test mssql on windows
334
- needs: job_build_gem
335
- runs-on: windows-latest
336
- strategy:
337
- fail-fast: false
338
- matrix:
339
- ruby: [3.1, 3.0, 2.7, 2.5]
340
- rails: [7, 6_1, 6, 5_2]
341
- exclude: [
342
- {ruby: 3.1, rails: 6 },
343
- {ruby: 3.1, rails: 5_2 },
344
- {ruby: 3.0, rails: 6 },
345
- {ruby: 3.0, rails: 5_2 },
346
- {ruby: 2.7, rails: 5_2 },
347
- {ruby: 2.5, rails: 7 },
348
- {ruby: jruby-9.2, rails: 7 },
349
- {ruby: jruby-9.2, rails: 6_1 },
350
- {ruby: jruby-9.2, rails: 6 },
351
- {ruby: jruby-9.3, rails: 7 },
352
- {ruby: jruby-9.3, rails: 6_1 },
353
- {ruby: jruby-9.3, rails: 6 },
354
- ]
355
- steps:
356
- - uses: actions/checkout@v2
357
- - name: Install mssql
358
- uses: potatoqualitee/mssqlsuite@v1
359
- with:
360
- install: sqlengine, sqlclient, sqlpackage, localdb
361
- sa-password: Password12!
362
- - name: Set up Ruby
363
- uses: MSP-Greg/ruby-setup-ruby@win-ucrt-1
364
- with:
365
- ruby-version: ${{ matrix.ruby }}
366
- - name: Install required packages on Windows
367
- shell: cmd
368
- run: |
369
- ridk exec sh -c "pacman --sync --needed --noconfirm ${MINGW_PACKAGE_PREFIX}-gcc"
370
- - name: Update system-wide gems
371
- run: gem update --system
372
- - name: Setup Gemfile
373
- if: ${{ matrix.rails != '5_2' }}
325
+ - name: Run test mssql [jruby]
326
+ if: ${{ contains(matrix.versions.ruby, 'jruby') }}
374
327
  run: |
375
- cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
376
- cp ./version_v2.rb lib/arel_extensions/version.rb
377
- cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
378
- - name: bundle install
379
- run: |
380
- bundle config set gemfile .\gemfiles\rails${{ matrix.rails }}.gemfile
381
- bundle install --verbose
382
- - name: Download gem from build job
383
- uses: actions/download-artifact@v2
384
- with:
385
- name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
386
- - name: Install downloaded gem
387
- run: gem install --local *.gem --verbose
388
- - name: Run test mssql
389
- run: bundle exec rake test:mssql
328
+ curl -LO https://github.com/microsoft/mssql-jdbc/releases/download/v8.4.1/mssql-jdbc-8.4.1.jre11.jar
329
+ CLASSPATH=".:mssql-jdbc-8.4.1.jre11.jar" bundle exec rake test:mssql
data/.gitignore CHANGED
@@ -1,9 +1,10 @@
1
- coverage/*
2
- config/database.yml
3
- spec/support/fixtures/*database*
4
1
  *.DS_Store
2
+ *.swp
3
+ .bundle
4
+ Gemfile.lock
5
+ config/database.yml
6
+ coverage/*
5
7
  debug.log
6
8
  pkg
7
- .bundle
8
- *.swp
9
- Gemfile.lock
9
+ spec/support/fixtures/*database*
10
+ vendor/
data/.rubocop.yml CHANGED
@@ -24,6 +24,10 @@ Layout/SpaceAroundEqualsInParameterDefault:
24
24
  Layout/SpaceAroundOperators:
25
25
  Enabled: true
26
26
 
27
+ Layout/SpaceInsideHashLiteralBraces:
28
+ Enabled: true
29
+ EnforcedStyle: no_space
30
+
27
31
  Layout/TrailingEmptyLines:
28
32
  Enabled: true
29
33
 
@@ -51,6 +55,10 @@ Style/EmptyElse:
51
55
  Style/Encoding:
52
56
  Enabled: true
53
57
 
58
+ Style/HashSyntax:
59
+ Enabled: true
60
+ EnforcedStyle: ruby19
61
+
54
62
  Style/MethodCallWithArgsParentheses:
55
63
  Enabled: false
56
64
 
@@ -60,9 +68,32 @@ Style/MethodCallWithoutArgsParentheses:
60
68
  Style/NegatedIf:
61
69
  Enabled: false
62
70
 
71
+ Style/NumericLiterals:
72
+ Enabled: true
73
+
74
+ Style/RedundantParentheses:
75
+ Enabled: true
76
+
77
+ Style/RedundantRegexpCharacterClass:
78
+ Enabled: true
79
+
80
+ Style/RedundantReturn:
81
+ Enabled: true
82
+
83
+ # Even when conservative, this is unsafe.
84
+ #Style/StringConcatenation:
85
+ # Enabled: true
86
+ # Mode: 'conservative'
87
+
63
88
  Style/StringLiterals:
64
89
  Enabled: true
65
90
 
91
+ Style/SymbolArray:
92
+ Enabled: true
93
+
94
+ Style/WordArray:
95
+ Enabled: true
96
+
66
97
  # Performance cops have been transferred to rubocop-performance gem.
67
98
  require: rubocop-performance
68
99
 
@@ -71,3 +102,9 @@ Performance/DoubleStartEndWith:
71
102
 
72
103
  Performance/RedundantMerge:
73
104
  Enabled: true
105
+
106
+ Performance/RegexpMatch:
107
+ Enabled: true
108
+
109
+ Performance/StringReplacement:
110
+ Enabled: true
data/Gemfile CHANGED
@@ -12,10 +12,10 @@ group :development, :test do
12
12
  gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
13
13
  gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
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', '~> 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]
17
17
 
18
- gem 'ruby-oci8', platforms: [:mri, :mswin, :x64_mingw, :mingw]
18
+ gem 'ruby-oci8', platforms: %i[mri mswin x64_mingw mingw]
19
19
  gem 'activerecord-oracle_enhanced-adapter', '~> 1.6.0'
20
20
 
21
21
  gem 'activesupport', '~> 6.0'
data/NEWS.md ADDED
@@ -0,0 +1,15 @@
1
+ # Release
2
+
3
+ ## Bug Fixes
4
+
5
+ - This used to fail.
6
+ ```
7
+ Arel.when(a).then(b).format('%Y-%m-%d')
8
+ ```
9
+
10
+ ## New Features
11
+
12
+ - `o.present`, a synonym for `o.not_blank`
13
+ - `o.coalesce_blank(a, b, c)`
14
+ - `o.if_present`, if the value is `null` or blank, then it returns `null`,
15
+ otherwise, it returns the value. Inspired by rails' `presence`.