arel_extensions 1.3.9 → 1.3.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 297d1d9b84e726d164e0e001cbe2402c81f3cb1491aa15f10854e508a65d0a8b
4
- data.tar.gz: 23697fa470d0524218097318b9f89a0d78e029e16bdeac5e23b24b6610369f6e
3
+ metadata.gz: 3400a56df8e4af91b1f3ad156e7e8d25de41fd5c197635c5c61fb028978ff82b
4
+ data.tar.gz: 6ea1115d046885b8c8a6a9da1eeeda63ed69525480cbccaadf3e577bc6026615
5
5
  SHA512:
6
- metadata.gz: 2e4bffd39e53121a46cf1aacc279747aae8e44119c6cdb3eba1e633e823ee2b3c13596f20139799be6a2ef619b7394aa1e0659569b63643bf08a8516777c84ac
7
- data.tar.gz: 1dc5fadc6064410bff969f77ab61b52308b0c60b2a2009868a40a6055b4194440763fd82a409c9a1b05911106b863ca1cc94066d954db0faf895caa7ce5516ed
6
+ metadata.gz: ef2ff44409e0f6d18e715d2cbdace94d8079b3c0ce5350463cb449e73182b2a30db645c5caf72bd7678678cba54a6d43ff31806627c9095a5878b66ad821b9e6
7
+ data.tar.gz: 9d9aaf84fb4289d7d23cd3bf039be28ed7ea231db4470d73ca96226f151bbfc1f43a43bd501d0e02adb3e9d6295c7d1c19476bae214292f05d0bf537c99d3f8b
@@ -3,7 +3,13 @@ name: Build and Test
3
3
  # Ruby + Rails Compatibility Matrix from here:
4
4
  # https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
5
5
 
6
- on: [push, pull_request]
6
+ on:
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
7
13
 
8
14
  jobs:
9
15
  job_test_to_sql:
@@ -12,33 +18,39 @@ jobs:
12
18
  strategy:
13
19
  fail-fast: false
14
20
  matrix:
15
- versions: [
16
- {ruby: '3.2', rails: 7_1, arelx: 2},
17
- {ruby: '3.2', rails: 7, arelx: 2},
18
- {ruby: '3.2', rails: 6_1, arelx: 2},
19
- {ruby: '3.1', rails: 7_1, arelx: 2},
20
- {ruby: '3.1', rails: 7, arelx: 2},
21
- {ruby: '3.1', rails: 6_1, arelx: 2},
22
- {ruby: '3.0', rails: 7_1, arelx: 2},
23
- {ruby: '3.0', rails: 7, arelx: 2},
24
- {ruby: '3.0', rails: 6_1, arelx: 2},
25
- {ruby: '2.7', rails: 7_1, arelx: 2},
26
- {ruby: '2.7', rails: 7, arelx: 2},
27
- {ruby: '2.7', rails: 6_1, arelx: 2},
28
- {ruby: '2.7', rails: 6, arelx: 2},
29
- {ruby: '2.7', rails: 5_2, arelx: 1},
30
- {ruby: '2.7', rails: 4_2, arelx: 1},
31
- {ruby: '2.5', rails: 6_1, arelx: 2},
32
- {ruby: '2.5', rails: 6, arelx: 2},
33
- {ruby: '2.5', rails: 5_2, arelx: 1},
34
- {ruby: '2.5', rails: 4_2, arelx: 1},
35
- {ruby: jruby-9.2, rails: 6_1, arelx: 2},
36
- {ruby: jruby-9.2, rails: 6, arelx: 2},
37
- {ruby: jruby-9.2, rails: 5_2, arelx: 1},
38
- {ruby: jruby-9.3, rails: 6_1, arelx: 2},
39
- {ruby: jruby-9.3, rails: 6, arelx: 2},
40
- {ruby: jruby-9.3, rails: 5_2, arelx: 1},
41
- ]
21
+ versions:
22
+ [
23
+ { ruby: "3.3", rails: 7_1, arelx: 2 },
24
+ { ruby: "3.3", rails: 7, arelx: 2 },
25
+ { ruby: "3.3", rails: 6_1, arelx: 2 },
26
+ { ruby: "3.2", rails: 7_1, arelx: 2 },
27
+ { ruby: "3.2", rails: 7, arelx: 2 },
28
+ { ruby: "3.2", rails: 6, arelx: 2 },
29
+ { ruby: "3.2", rails: 6_1, arelx: 2 },
30
+ { ruby: "3.1", rails: 7_1, arelx: 2 },
31
+ { ruby: "3.1", rails: 7, arelx: 2 },
32
+ { ruby: "3.1", rails: 6_1, arelx: 2 },
33
+ { ruby: "3.1", rails: 6, arelx: 2 },
34
+ { ruby: "3.0", rails: 7_1, arelx: 2 },
35
+ { ruby: "3.0", rails: 7, arelx: 2 },
36
+ { ruby: "3.0", rails: 6_1, arelx: 2 },
37
+ { ruby: "2.7", rails: 7_1, arelx: 2 },
38
+ { ruby: "2.7", rails: 7, arelx: 2 },
39
+ { ruby: "2.7", rails: 6_1, arelx: 2 },
40
+ { ruby: "2.7", rails: 6, arelx: 2 },
41
+ { ruby: "2.7", rails: 5_2, arelx: 1 },
42
+ { ruby: "2.7", rails: 4_2, arelx: 1 },
43
+ { ruby: "2.5", rails: 6_1, arelx: 2 },
44
+ { ruby: "2.5", rails: 6, arelx: 2 },
45
+ { ruby: "2.5", rails: 5_2, arelx: 1 },
46
+ { ruby: "2.5", rails: 4_2, arelx: 1 },
47
+ { ruby: jruby-9.2, rails: 6_1, arelx: 2 },
48
+ { ruby: jruby-9.2, rails: 6, arelx: 2 },
49
+ { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
50
+ { ruby: jruby-9.3, rails: 6_1, arelx: 2 },
51
+ { ruby: jruby-9.3, rails: 6, arelx: 2 },
52
+ { ruby: jruby-9.3, rails: 5_2, arelx: 1 },
53
+ ]
42
54
  steps:
43
55
  - uses: actions/checkout@v2
44
56
  - name: Set up Ruby
@@ -68,34 +80,40 @@ jobs:
68
80
  strategy:
69
81
  fail-fast: false
70
82
  matrix:
71
- versions: [
72
- {ruby: '3.2', rails: 7_1, arelx: 2},
73
- {ruby: '3.2', rails: 7, arelx: 2},
74
- {ruby: '3.2', rails: 6_1, arelx: 2},
75
- {ruby: '3.1', rails: 7_1, arelx: 2},
76
- {ruby: '3.1', rails: 7, arelx: 2},
77
- {ruby: '3.1', rails: 6_1, arelx: 2},
78
- {ruby: '3.0', rails: 7_1, arelx: 2},
79
- {ruby: '3.0', rails: 7, arelx: 2},
80
- {ruby: '3.0', rails: 6_1, arelx: 2},
81
- {ruby: '2.7', rails: 7_1, arelx: 2},
82
- {ruby: '2.7', rails: 7, arelx: 2},
83
- {ruby: '2.7', rails: 6_1, arelx: 2},
84
- {ruby: '2.7', rails: 6, arelx: 2},
85
- {ruby: '2.7', rails: 5_2, arelx: 1},
86
- {ruby: '2.7', rails: 4_2, arelx: 1},
87
- {ruby: '2.5', rails: 6_1, arelx: 2},
88
- {ruby: '2.5', rails: 6, arelx: 2},
89
- {ruby: '2.5', rails: 5_2, arelx: 1},
90
- {ruby: '2.5', rails: 4_2, arelx: 1},
91
- {ruby: jruby-9.2, rails: 6_1, arelx: 2},
92
- {ruby: jruby-9.2, rails: 6, arelx: 2},
93
- {ruby: jruby-9.2, rails: 5_2, arelx: 1},
94
- {ruby: jruby-9.2, rails: 4_2, arelx: 1},
95
- {ruby: jruby-9.3, rails: 6_1, arelx: 2},
96
- {ruby: jruby-9.3, rails: 6, arelx: 2},
97
- {ruby: jruby-9.3, rails: 5_2, arelx: 1},
98
- ]
83
+ versions:
84
+ [
85
+ { ruby: "3.3", rails: 7_1, arelx: 2 },
86
+ { ruby: "3.3", rails: 7, arelx: 2 },
87
+ { ruby: "3.3", rails: 6_1, arelx: 2 },
88
+ { ruby: "3.2", rails: 7_1, arelx: 2 },
89
+ { ruby: "3.2", rails: 7, arelx: 2 },
90
+ { ruby: "3.2", rails: 6_1, arelx: 2 },
91
+ { ruby: "3.2", rails: 6, arelx: 2 },
92
+ { ruby: "3.1", rails: 7_1, arelx: 2 },
93
+ { ruby: "3.1", rails: 7, arelx: 2 },
94
+ { ruby: "3.1", rails: 6, arelx: 2 },
95
+ { ruby: "3.1", rails: 6_1, arelx: 2 },
96
+ { ruby: "3.0", rails: 7_1, arelx: 2 },
97
+ { ruby: "3.0", rails: 7, arelx: 2 },
98
+ { ruby: "3.0", rails: 6_1, arelx: 2 },
99
+ { ruby: "2.7", rails: 7_1, arelx: 2 },
100
+ { ruby: "2.7", rails: 7, arelx: 2 },
101
+ { ruby: "2.7", rails: 6_1, arelx: 2 },
102
+ { ruby: "2.7", rails: 6, arelx: 2 },
103
+ { ruby: "2.7", rails: 5_2, arelx: 1 },
104
+ { ruby: "2.7", rails: 4_2, arelx: 1 },
105
+ { ruby: "2.5", rails: 6_1, arelx: 2 },
106
+ { ruby: "2.5", rails: 6, arelx: 2 },
107
+ { ruby: "2.5", rails: 5_2, arelx: 1 },
108
+ { ruby: "2.5", rails: 4_2, arelx: 1 },
109
+ { ruby: jruby-9.2, rails: 6_1, arelx: 2 },
110
+ { ruby: jruby-9.2, rails: 6, arelx: 2 },
111
+ { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
112
+ { ruby: jruby-9.2, rails: 4_2, arelx: 1 },
113
+ { ruby: jruby-9.3, rails: 6_1, arelx: 2 },
114
+ { ruby: jruby-9.3, rails: 6, arelx: 2 },
115
+ { ruby: jruby-9.3, rails: 5_2, arelx: 1 },
116
+ ]
99
117
  steps:
100
118
  - uses: actions/checkout@v2
101
119
  - name: Set up Ruby
@@ -126,33 +144,38 @@ jobs:
126
144
  fail-fast: false
127
145
  matrix:
128
146
  versions: [
129
- {ruby: '3.2', rails: 7_1, arelx: 2},
130
- {ruby: '3.2', rails: 7, arelx: 2},
131
- {ruby: '3.2', rails: 6_1, arelx: 2},
132
- {ruby: '3.1', rails: 7_1, arelx: 2},
133
- {ruby: '3.1', rails: 7, arelx: 2},
134
- {ruby: '3.1', rails: 6_1, arelx: 2},
135
- {ruby: '3.0', rails: 7_1, arelx: 2},
136
- {ruby: '3.0', rails: 7, arelx: 2},
137
- {ruby: '3.0', rails: 6_1, arelx: 2},
138
- {ruby: '2.7', rails: 7_1, arelx: 2},
139
- {ruby: '2.7', rails: 7, arelx: 2},
140
- {ruby: '2.7', rails: 6_1, arelx: 2},
141
- {ruby: '2.7', rails: 6, arelx: 2},
142
- {ruby: '2.7', rails: 5_2, arelx: 1},
143
- {ruby: '2.7', rails: 4_2, arelx: 1},
144
- {ruby: '2.5', rails: 6_1, arelx: 2},
145
- {ruby: '2.5', rails: 6, arelx: 2},
146
- {ruby: '2.5', rails: 5_2, arelx: 1},
147
- {ruby: '2.5', rails: 4_2, arelx: 1},
148
- {ruby: jruby-9.2, rails: 6_1, arelx: 2},
149
- {ruby: jruby-9.2, rails: 6, arelx: 2},
150
- {ruby: jruby-9.2, rails: 5_2, arelx: 1},
151
- {ruby: jruby-9.2, rails: 4_2, arelx: 1},
152
- {ruby: jruby-9.3, rails: 6_1, arelx: 2},
153
- {ruby: jruby-9.3, rails: 6, arelx: 2},
154
- {ruby: jruby-9.3, rails: 5_2, arelx: 1},
155
- ]
147
+ { ruby: "3.3", rails: 7_1, arelx: 2 },
148
+ { ruby: "3.3", rails: 7, arelx: 2 },
149
+ { ruby: "3.3", rails: 6_1, arelx: 2 },
150
+ { ruby: "3.2", rails: 7_1, arelx: 2 },
151
+ { ruby: "3.2", rails: 7, arelx: 2 },
152
+ { ruby: "3.2", rails: 6_1, arelx: 2 },
153
+ # { ruby: "3.2", rails: 6, arelx: 2 }, # cannot test > undefined symbol: rb_tainted_str_new2
154
+ { ruby: "3.1", rails: 7_1, arelx: 2 },
155
+ { ruby: "3.1", rails: 7, arelx: 2 },
156
+ { ruby: "3.1", rails: 6_1, arelx: 2 },
157
+ { ruby: "3.1", rails: 6, arelx: 2 },
158
+ { ruby: "3.0", rails: 7_1, arelx: 2 },
159
+ { ruby: "3.0", rails: 7, arelx: 2 },
160
+ { ruby: "3.0", rails: 6_1, arelx: 2 },
161
+ { ruby: "2.7", rails: 7_1, arelx: 2 },
162
+ { ruby: "2.7", rails: 7, arelx: 2 },
163
+ { ruby: "2.7", rails: 6_1, arelx: 2 },
164
+ { ruby: "2.7", rails: 6, arelx: 2 },
165
+ { ruby: "2.7", rails: 5_2, arelx: 1 },
166
+ { ruby: "2.7", rails: 4_2, arelx: 1 },
167
+ { ruby: "2.5", rails: 6_1, arelx: 2 },
168
+ { ruby: "2.5", rails: 6, arelx: 2 },
169
+ { ruby: "2.5", rails: 5_2, arelx: 1 },
170
+ { ruby: "2.5", rails: 4_2, arelx: 1 },
171
+ { ruby: jruby-9.2, rails: 6_1, arelx: 2 },
172
+ { ruby: jruby-9.2, rails: 6, arelx: 2 },
173
+ { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
174
+ { ruby: jruby-9.2, rails: 4_2, arelx: 1 },
175
+ { ruby: jruby-9.3, rails: 6_1, arelx: 2 },
176
+ { ruby: jruby-9.3, rails: 6, arelx: 2 },
177
+ { ruby: jruby-9.3, rails: 5_2, arelx: 1 },
178
+ ]
156
179
  steps:
157
180
  - uses: actions/checkout@v2
158
181
  # PostgreSQL requires locales to be installed on the system to be able
@@ -208,33 +231,38 @@ jobs:
208
231
  fail-fast: false
209
232
  matrix:
210
233
  versions: [
211
- {ruby: '3.2', rails: 7_1, arelx: 2},
212
- {ruby: '3.2', rails: 7, arelx: 2},
213
- {ruby: '3.2', rails: 6_1, arelx: 2},
214
- {ruby: '3.1', rails: 7_1, arelx: 2},
215
- {ruby: '3.1', rails: 7, arelx: 2},
216
- {ruby: '3.1', rails: 6_1, arelx: 2},
217
- {ruby: '3.0', rails: 7_1, arelx: 2},
218
- {ruby: '3.0', rails: 7, arelx: 2},
219
- {ruby: '3.0', rails: 6_1, arelx: 2},
220
- {ruby: '2.7', rails: 7_1, arelx: 2},
221
- {ruby: '2.7', rails: 7, arelx: 2},
222
- {ruby: '2.7', rails: 6_1, arelx: 2},
223
- {ruby: '2.7', rails: 6, arelx: 2},
224
- {ruby: '2.7', rails: 5_2, arelx: 1},
225
- {ruby: '2.7', rails: 4_2, arelx: 1},
226
- {ruby: '2.5', rails: 6_1, arelx: 2},
227
- {ruby: '2.5', rails: 6, arelx: 2},
228
- {ruby: '2.5', rails: 5_2, arelx: 1},
229
- {ruby: '2.5', rails: 4_2, arelx: 1},
230
- {ruby: jruby-9.2, rails: 6_1, arelx: 2},
231
- {ruby: jruby-9.2, rails: 6, arelx: 2},
232
- {ruby: jruby-9.2, rails: 5_2, arelx: 1},
233
- {ruby: jruby-9.2, rails: 4_2, arelx: 1},
234
- {ruby: jruby-9.3, rails: 6_1, arelx: 2},
235
- {ruby: jruby-9.3, rails: 6, arelx: 2},
236
- {ruby: jruby-9.3, rails: 5_2, arelx: 1},
237
- ]
234
+ { ruby: "3.3", rails: 7_1, arelx: 2 },
235
+ { ruby: "3.3", rails: 7, arelx: 2 },
236
+ { ruby: "3.3", rails: 6_1, arelx: 2 },
237
+ { ruby: "3.2", rails: 7_1, arelx: 2 },
238
+ { ruby: "3.2", rails: 7, arelx: 2 },
239
+ { ruby: "3.2", rails: 6_1, arelx: 2 },
240
+ # { ruby: "3.2", rails: 6, arelx: 2 }, # cannot test > undefined symbol: rb_tainted_str_new2
241
+ { ruby: "3.1", rails: 7_1, arelx: 2 },
242
+ { ruby: "3.1", rails: 7, arelx: 2 },
243
+ { ruby: "3.1", rails: 6_1, arelx: 2 },
244
+ { ruby: "3.1", rails: 6, arelx: 2 },
245
+ { ruby: "3.0", rails: 7_1, arelx: 2 },
246
+ { ruby: "3.0", rails: 7, arelx: 2 },
247
+ { ruby: "3.0", rails: 6_1, arelx: 2 },
248
+ { ruby: "2.7", rails: 7_1, arelx: 2 },
249
+ { ruby: "2.7", rails: 7, arelx: 2 },
250
+ { ruby: "2.7", rails: 6_1, arelx: 2 },
251
+ { ruby: "2.7", rails: 6, arelx: 2 },
252
+ { ruby: "2.7", rails: 5_2, arelx: 1 },
253
+ { ruby: "2.7", rails: 4_2, arelx: 1 },
254
+ { ruby: "2.5", rails: 6_1, arelx: 2 },
255
+ { ruby: "2.5", rails: 6, arelx: 2 },
256
+ { ruby: "2.5", rails: 5_2, arelx: 1 },
257
+ { ruby: "2.5", rails: 4_2, arelx: 1 },
258
+ { ruby: jruby-9.2, rails: 6_1, arelx: 2 },
259
+ { ruby: jruby-9.2, rails: 6, arelx: 2 },
260
+ { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
261
+ { ruby: jruby-9.2, rails: 4_2, arelx: 1 },
262
+ { ruby: jruby-9.3, rails: 6_1, arelx: 2 },
263
+ { ruby: jruby-9.3, rails: 6, arelx: 2 },
264
+ { ruby: jruby-9.3, rails: 5_2, arelx: 1 },
265
+ ]
238
266
  services:
239
267
  mysql:
240
268
  image: mysql:5.7
@@ -285,29 +313,48 @@ jobs:
285
313
  fail-fast: false
286
314
  matrix:
287
315
  versions: [
288
- # {ruby: '3.2', rails: 7, arelx: 2},
289
- {ruby: '3.2', rails: 6_1, arelx: 2},
290
- # {ruby: '3.1', rails: 7, arelx: 2},
291
- {ruby: '3.1', rails: 6_1, arelx: 2},
292
- # {ruby: '3.0', rails: 7, arelx: 2},
293
- {ruby: '3.0', rails: 6_1, arelx: 2},
294
- # {ruby: '2.7', rails: 7, arelx: 2},
295
- {ruby: '2.7', rails: 6_1, arelx: 2},
296
- {ruby: '2.7', rails: 6, arelx: 2},
297
- {ruby: '2.7', rails: 5_2, arelx: 1},
298
- {ruby: '2.7', rails: 4_2, arelx: 1},
299
- {ruby: '2.5', rails: 6_1, arelx: 2},
300
- {ruby: '2.5', rails: 6, arelx: 2},
301
- {ruby: '2.5', rails: 5_2, arelx: 1},
302
- {ruby: '2.5', rails: 4_2, arelx: 1},
303
- # {ruby: jruby-9.2, rails: 6_1, arelx: 2},
304
- # {ruby: jruby-9.2, rails: 6, arelx: 2},
305
- {ruby: jruby-9.2, rails: 5_2, arelx: 1},
306
- {ruby: jruby-9.2, rails: 4_2, arelx: 1},
307
- # {ruby: jruby-9.3, rails: 6_1, arelx: 2},
308
- # {ruby: jruby-9.3, rails: 6, arelx: 2},
309
- {ruby: jruby-9.3, rails: 5_2, arelx: 1},
310
- ]
316
+ { ruby: "3.3", rails: 7_1, arelx: 2 },
317
+ { ruby: "3.3", rails: 7, arelx: 2 },
318
+ { ruby: "3.3", rails: 6_1, arelx: 2 },
319
+ { ruby: "3.3", rails: 6, arelx: 2 },
320
+ { ruby: "3.2", rails: 7_1, arelx: 2 },
321
+ { ruby: "3.2", rails: 7, arelx: 2 },
322
+ { ruby: "3.2", rails: 6_1, arelx: 2 },
323
+ { ruby: "3.2", rails: 6, arelx: 2 },
324
+ { ruby: "3.1", rails: 7_1, arelx: 2 },
325
+ { ruby: "3.1", rails: 7, arelx: 2 },
326
+ { ruby: "3.1", rails: 6_1, arelx: 2 },
327
+ { ruby: "3.1", rails: 6, arelx: 2 },
328
+ { ruby: "3.0", rails: 7, arelx: 2 },
329
+ { ruby: "3.0", rails: 6_1, arelx: 2 },
330
+ { ruby: "3.0", rails: 6, arelx: 2 },
331
+ { ruby: "2.7", rails: 6_1, arelx: 2 },
332
+ { ruby: "2.7", rails: 6, arelx: 2 },
333
+ { ruby: "2.7", rails: 5_2, arelx: 1 },
334
+ { ruby: "2.7", rails: 4_2, arelx: 1 },
335
+ { ruby: "2.5", rails: 6_1, arelx: 2 },
336
+ { ruby: "2.5", rails: 6, arelx: 2 },
337
+ { ruby: "2.5", rails: 5_2, arelx: 1 },
338
+ { ruby: "2.5", rails: 4_2, arelx: 1 },
339
+ # {ruby: jruby-9.2, rails: 6_1, arelx: 2},
340
+ # {ruby: jruby-9.2, rails: 6, arelx: 2},
341
+ { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
342
+ { ruby: jruby-9.2, rails: 4_2, arelx: 1 },
343
+ # See comments on 9.4 to understand why these are disabled for now.
344
+ # {ruby: jruby-9.3, rails: 6_1, arelx: 2},
345
+ # {ruby: jruby-9.3, rails: 6, arelx: 2},
346
+ # {ruby: jruby-9.3, rails: 5_2, arelx: 1},
347
+ { ruby: jruby-9.4, rails: 7_1, arelx: 2 },
348
+ { ruby: jruby-9.4, rails: 7, arelx: 2 },
349
+ #
350
+ # 6 and 6.1 don't work because of a bug in the alt adapter
351
+ # https://github.com/JesseChavez/activerecord-jdbc-adapter/issues/16
352
+ # {ruby: jruby-9.4, rails: 6_1, arelx: 2},
353
+ # {ruby: jruby-9.4, rails: 6, arelx: 2},
354
+ #
355
+ # < 5.2 don't work because of a deeper issue.
356
+ # {ruby: jruby-9.4, rails: 5_2, arelx: 1},
357
+ ]
311
358
  mssql: [2017, 2019]
312
359
  steps:
313
360
  - uses: actions/checkout@v2
data/NEWS.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # News
2
2
 
3
+ ## Release v2.1.11/v1.3.11
4
+
5
+ - MS SQL: turn on warnings on requires only when necessary.
6
+
7
+ ## Release v2.1.10/v1.3.10
8
+
9
+ - MS SQL: add support for jruby 9.4 via [activerecord-jdbc-alt-adapter](https://rubygems.org/gems/activerecord-jdbc-alt-adapter/)
10
+
3
11
  ## Release v2.1.9/v1.3.9
4
12
 
5
13
  ### Bug Fixes
data/README.md CHANGED
@@ -772,7 +772,7 @@ bundle exec rake test:to_sql
772
772
  Refer to the [Version Compatibility](#version-compatibility) section to correctly
773
773
  set your gemfile.
774
774
 
775
- ### MariaDB and Postgres
775
+ ### Testing databases locally
776
776
 
777
777
  We provide a `docker compose` to set up some databases for testing:
778
778
 
data/dev/compose.yaml CHANGED
@@ -27,3 +27,11 @@ services:
27
27
  interval: 10s
28
28
  timeout: 5s
29
29
  retries: 3
30
+ mssql:
31
+ image: mcr.microsoft.com/mssql/server:2019-latest
32
+ container_name: mssql
33
+ environment:
34
+ MSSQL_SA_PASSWORD: Password12!
35
+ ACCEPT_EULA: Y
36
+ ports:
37
+ - "1433:1433"
@@ -20,11 +20,12 @@ group :development, :test do
20
20
  gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0' if ENV.has_key? 'ORACLE_HOME'
21
21
 
22
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
23
+ gem 'activerecord-jdbc-alt-adapter', '~> 60.0', platform: :jruby, require: true
26
24
  gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
27
25
  gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
26
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
27
+ gem 'jdbc-mssql', platforms: :jruby, require: true
28
+ gem 'jdbc-sqlite3', platforms: :jruby
28
29
  end
29
30
 
30
31
  gemspec path: Dir.pwd
@@ -20,11 +20,12 @@ group :development, :test do
20
20
  gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0' if ENV.has_key? 'ORACLE_HOME'
21
21
 
22
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
23
+ gem 'activerecord-jdbc-alt-adapter', '~> 61.0', platform: :jruby, require: true
26
24
  gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
27
25
  gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
26
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
27
+ gem 'jdbc-mssql', platforms: :jruby, require: true
28
+ gem 'jdbc-sqlite3', platforms: :jruby
28
29
  end
29
30
 
30
31
  gemspec path: Dir.pwd
@@ -13,11 +13,19 @@ group :development, :test do
13
13
  gem 'pg', '~> 1.1', platforms: [:mri]
14
14
 
15
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]
16
+ gem 'activerecord-sqlserver-adapter', '~> 7.0.7', platforms: %i[mri mingw x64_mingw mswin]
17
17
  gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw]
18
18
 
19
19
  gem 'ruby-oci8', platforms: %i[mri mswin mingw] if ENV.has_key? 'ORACLE_HOME'
20
20
  gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0' if ENV.has_key? 'ORACLE_HOME'
21
+
22
+ # for JRuby
23
+ gem 'jdbc-mssql', platforms: :jruby, require: true
24
+ gem 'jdbc-sqlite3', platform: :jruby
25
+ gem 'activerecord-jdbc-alt-adapter', '~> 70.0', platform: :jruby, require: true
26
+ gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
27
+ gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
28
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
21
29
  end
22
30
 
23
31
  gemspec path: Dir.pwd
@@ -17,6 +17,14 @@ group :development, :test do
17
17
 
18
18
  gem 'ruby-oci8', platforms: %i[mri mswin mingw] if ENV.has_key? 'ORACLE_HOME'
19
19
  gem 'activerecord-oracle_enhanced-adapter', '~> 7.0.0' if ENV.has_key? 'ORACLE_HOME'
20
+
21
+ # for JRuby
22
+ gem 'jdbc-mssql', platforms: :jruby, require: true
23
+ gem 'jdbc-sqlite3', platform: :jruby
24
+ gem 'activerecord-jdbc-alt-adapter', '~> 71.0.0.alpha1', platform: :jruby, require: true
25
+ gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
26
+ gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
27
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
20
28
  end
21
29
 
22
30
  gemspec path: Dir.pwd
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = '1.3.9'.freeze
2
+ VERSION = '1.3.11'.freeze
3
3
  end
@@ -2,52 +2,68 @@ module ArelExtensions
2
2
  module Visitors
3
3
  module MSSQL
4
4
 
5
- mssql_class = Arel::Visitors.constants.select { |c|
6
- Arel::Visitors.const_get(c).is_a?(Class) && %i[MSSQL SQLServer].include?(c)
7
- }.first
8
-
9
- LOADED_VISITOR = Arel::Visitors.const_get(mssql_class) || Arel::Visitors.const_get('MSSQL')
10
-
11
- LOADED_VISITOR::DATE_MAPPING = {
12
- 'd' => 'day', 'm' => 'month', 'y' => 'year', 'wd' => 'weekday', 'w' => 'week', 'h' => 'hour', 'mn' => 'minute', 's' => 'second'
13
- }.freeze
14
-
15
- LOADED_VISITOR::DATE_FORMAT_DIRECTIVES = {
16
- '%Y' => 'YYYY', '%C' => '', '%y' => 'YY', '%m' => 'MM', '%B' => 'month', '%^B' => '', '%b' => '', '%^b' => '', # year, month
17
- '%V' => 'iso_week', '%G' => '', # ISO week number and year of week
18
- '%d' => 'DD', '%e' => '' , '%j' => '' , '%w' => 'dw', %'a' => '', '%A' => 'weekday', # day, weekday
19
- '%H' => 'hh', '%k' => '' , '%I' => '' , '%l' => '' , '%P' => '', '%p' => '', # hours
20
- '%M' => 'mi', '%S' => 'ss', '%L' => 'ms', '%N' => 'ns', '%z' => 'tz'
21
- }.freeze
22
-
23
- LOADED_VISITOR::DATE_FORMAT_FORMAT = {
24
- 'YY' => '0#', 'MM' => '0#', 'DD' => '0#', 'hh' => '0#', 'mi' => '0#', 'ss' => '0#', 'iso_week' => '0#'
25
- }
26
-
27
- LOADED_VISITOR::DATE_NAME = [
28
- '%B', '%A'
29
- ]
30
-
31
- LOADED_VISITOR::DATE_FORMAT_REGEX =
32
- Regexp.new(
33
- LOADED_VISITOR::DATE_FORMAT_DIRECTIVES
34
- .keys
35
- .map{|k| Regexp.escape(k)}
36
- .join('|')
37
- ).freeze
38
-
39
- # TODO; all others... http://www.sql-server-helper.com/tips/date-formats.aspx
40
- LOADED_VISITOR::DATE_CONVERT_FORMATS = {
41
- 'YYYY-MM-DD' => 120,
42
- 'YY-MM-DD' => 120,
43
- 'MM/DD/YYYY' => 101,
44
- 'MM-DD-YYYY' => 110,
45
- 'YYYY/MM/DD' => 111,
46
- 'DD-MM-YYYY' => 105,
47
- 'DD-MM-YY' => 5,
48
- 'DD.MM.YYYY' => 104,
49
- 'YYYY-MM-DDTHH:MM:SS:MMM' => 126
50
- }.freeze
5
+ MSSQL_CLASS_NAMES = %i[MSSQL SQLServer].freeze
6
+
7
+ mssql_class =
8
+ Arel::Visitors
9
+ .constants
10
+ .select { |c| Arel::Visitors.const_get(c).is_a?(Class) }
11
+ .find { |c| MSSQL_CLASS_NAMES.include?(c) }
12
+
13
+ # This guard is necessary because:
14
+ #
15
+ # 1. const_get(mssql_class) will fail when mssql_class is nil.
16
+ # 2. mssql_class could be nil under certain conditions:
17
+ # 1. especially on ruby 2.5 (and surprisingly not jruby 9.2) and 3.0+.
18
+ # 2. when not working with mssql itself.
19
+ if mssql_class
20
+ LOADED_VISITOR = Arel::Visitors.const_get(mssql_class)
21
+
22
+ LOADED_VISITOR::DATE_MAPPING = {
23
+ 'd' => 'day', 'm' => 'month', 'y' => 'year',
24
+ 'wd' => 'weekday', 'w' => 'week',
25
+ 'h' => 'hour', 'mn' => 'minute', 's' => 'second'
26
+ }.freeze
27
+
28
+ LOADED_VISITOR::DATE_FORMAT_DIRECTIVES = {
29
+ '%Y' => 'YYYY', '%C' => '', '%y' => 'YY', '%m' => 'MM', '%B' => 'month', '%^B' => '', '%b' => '', '%^b' => '', # year, month
30
+ '%V' => 'iso_week', '%G' => '', # ISO week number and year of week
31
+ '%d' => 'DD', '%e' => '' , '%j' => '' , '%w' => 'dw', %'a' => '', '%A' => 'weekday', # day, weekday
32
+ '%H' => 'hh', '%k' => '' , '%I' => '' , '%l' => '' , '%P' => '', '%p' => '', # hours
33
+ '%M' => 'mi', '%S' => 'ss', '%L' => 'ms', '%N' => 'ns', '%z' => 'tz'
34
+ }.freeze
35
+
36
+ LOADED_VISITOR::DATE_FORMAT_FORMAT = {
37
+ 'YY' => '0#', 'MM' => '0#', 'DD' => '0#',
38
+ 'hh' => '0#', 'mi' => '0#', 'ss' => '0#',
39
+ 'iso_week' => '0#'
40
+ }
41
+
42
+ LOADED_VISITOR::DATE_NAME = [
43
+ '%B', '%A'
44
+ ]
45
+
46
+ LOADED_VISITOR::DATE_FORMAT_REGEX =
47
+ Regexp.new(
48
+ LOADED_VISITOR::DATE_FORMAT_DIRECTIVES
49
+ .keys
50
+ .map{|k| Regexp.escape(k)}
51
+ .join('|')
52
+ ).freeze
53
+
54
+ # TODO; all others... http://www.sql-server-helper.com/tips/date-formats.aspx
55
+ LOADED_VISITOR::DATE_CONVERT_FORMATS = {
56
+ 'YYYY-MM-DD' => 120,
57
+ 'YY-MM-DD' => 120,
58
+ 'MM/DD/YYYY' => 101,
59
+ 'MM-DD-YYYY' => 110,
60
+ 'YYYY/MM/DD' => 111,
61
+ 'DD-MM-YYYY' => 105,
62
+ 'DD-MM-YY' => 5,
63
+ 'DD.MM.YYYY' => 104,
64
+ 'YYYY-MM-DDTHH:MM:SS:MMM' => 126
65
+ }.freeze
66
+ end
51
67
 
52
68
  # Quoting in JRuby + AR < 5 requires special handling for MSSQL.
53
69
  #
@@ -57,9 +73,10 @@ module ArelExtensions
57
73
  # It didn't handle numbers correctly: `quote(1, nil)` translated into
58
74
  # `N'1'` which we don't want.
59
75
  #
60
- # The following is adapted from activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
76
+ # The following is adapted from
77
+ # https://github.com/rails/rails/blob/main/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
61
78
  #
62
- if RUBY_PLATFORM == 'java' && ActiveRecord::VERSION::MAJOR < 5
79
+ if RUBY_PLATFORM == 'java'
63
80
  def quote_string(s)
64
81
  s.gsub('\\', '\&\&').gsub("'", "''") # ' (for ruby-mode)
65
82
  end
@@ -70,14 +87,15 @@ module ArelExtensions
70
87
 
71
88
  def quoted_date(value)
72
89
  if value.acts_like?(:time)
73
- if ActiveRecord::Base.default_timezone == :utc
90
+ if (ActiveRecord.respond_to?(:default_timezone) && ActiveRecord.default_timezone == :utc) || ActiveRecord::Base.default_timezone == :utc
74
91
  value = value.getutc if value.respond_to?(:getutc) && !value.utc?
75
92
  else
76
93
  value = value.getlocal if value.respond_to?(:getlocal)
77
94
  end
78
95
  end
79
-
80
- result = value.to_s(:db)
96
+ # new versions of AR use `to_fs`, but we want max compatibility, and we're
97
+ # not going to write it over and over, so it's fine like that.
98
+ result = value.to_formatted_s(:db)
81
99
  if value.respond_to?(:usec) && value.usec > 0
82
100
  result << '.' << sprintf('%06d', value.usec)
83
101
  else
@@ -104,17 +122,19 @@ module ArelExtensions
104
122
  value
105
123
  when String, Symbol, ActiveSupport::Multibyte::Chars
106
124
  "'#{quote_string(value.to_s)}'"
107
- when true
125
+ when true
108
126
  quoted_true
109
- when false
127
+ when false
110
128
  quoted_false
111
- when nil
129
+ when nil
112
130
  'NULL'
113
131
  # BigDecimals need to be put in a non-normalized form and quoted.
114
132
  when BigDecimal
115
133
  value.to_s('F')
116
134
  when Numeric, ActiveSupport::Duration
117
135
  value.to_s
136
+ when Arel::VERSION.to_i > 6 && ActiveRecord::Type::Time::Value
137
+ "'#{quoted_time(value)}'"
118
138
  when Date, Time
119
139
  "'#{quoted_date(value)}'"
120
140
  when Class
@@ -125,6 +145,15 @@ module ArelExtensions
125
145
  end
126
146
  end
127
147
 
148
+ alias_method(:old_primary_Key_From_Table, :primary_Key_From_Table) rescue nil
149
+ def primary_Key_From_Table t
150
+ return unless t
151
+
152
+ column_name = @connection.schema_cache.primary_keys(t.name) ||
153
+ @connection.schema_cache.columns_hash(t.name).first.try(:second).try(:name)
154
+ column_name ? t[column_name] : nil
155
+ end
156
+
128
157
  # Math Functions
129
158
  def visit_ArelExtensions_Nodes_Ceil o, collector
130
159
  collector << 'CEILING('
@@ -543,14 +572,21 @@ module ArelExtensions
543
572
  collector = visit o.left, collector
544
573
  end
545
574
  collector << ' AS '
546
-
547
- # sometimes these values are already quoted, if they are, don't double quote it
548
- quote = o.right.is_a?(Arel::Nodes::SqlLiteral) && o.right[0] != '"' && o.right[-1] != '"'
549
-
550
- collector << '"' if quote
575
+ # Sometimes these values are already quoted, if they are, don't double quote it
576
+ lft, rgt =
577
+ if o.right.is_a?(Arel::Nodes::SqlLiteral)
578
+ if Arel::VERSION.to_i >= 6 && o.right[0] != '[' && o.right[-1] != ']'
579
+ # This is a lie, it's not about arel version, but SQL Server's (>= 2000).
580
+ ['[', ']']
581
+ elsif o.right[0] != '"' && o.right[-1] != '"'
582
+ ['"', '"']
583
+ else
584
+ []
585
+ end
586
+ end
587
+ collector << lft if lft
551
588
  collector = visit o.right, collector
552
- collector << '"' if quote
553
-
589
+ collector << rgt if rgt
554
590
  collector
555
591
  end
556
592
 
@@ -158,10 +158,10 @@ module ArelExtensions
158
158
  collector = visit o.expressions.first, collector
159
159
  collector <<
160
160
  if o.ai
161
- " COLLATE #{charset == 'latin1' ? 'latin1_general_ci' : 'utf8_unicode_ci'}"
161
+ " COLLATE #{charset == 'latin1' ? 'latin1_general_ci' : "#{charset}_unicode_ci"}"
162
162
  # doesn't work in latin1
163
163
  elsif o.ci
164
- " COLLATE #{charset == 'latin1' ? 'latin1_general_ci' : 'utf8_unicode_ci'}"
164
+ " COLLATE #{charset == 'latin1' ? 'latin1_general_ci' : "#{charset}_unicode_ci"}"
165
165
  else
166
166
  " COLLATE #{charset}_bin"
167
167
  end
@@ -1,6 +1,30 @@
1
+ # MSSQL visitors for java and rails ≥ 7 are painful to work with:
2
+ # requiring the exact path to the visitor is needed even if the
3
+ # AR adapter was loaded. It's also needed exactly here because:
4
+ # 1. putting it inside the visitor or anywhere else will not
5
+ # guarantee its actual loading.
6
+ # 2. it needs to load before arel_extensions/visitors.
7
+ if RUBY_PLATFORM == 'java' \
8
+ && RUBY_ENGINE == 'jruby' \
9
+ && (version = JRUBY_VERSION.split('.').map(&:to_i)) && version[0] == 9 && version[1] >= 4 \
10
+ && Gem::Specification.find { |g| g.name == 'jdbc-mssql' }
11
+ begin
12
+ require 'arel/visitors/sqlserver'
13
+ rescue LoadError
14
+ warn 'arel/visitors/sqlserver not found: MSSQL might not work correctly.'
15
+ end
16
+ elsif RUBY_PLATFORM != 'java' && Arel::VERSION.to_i < 10
17
+ begin
18
+ require 'arel_sqlserver'
19
+ rescue LoadError
20
+ warn 'arel_sqlserver not found: SQLServer Visitor might not work correctly.'
21
+ end
22
+ end
23
+
1
24
  require 'arel_extensions/visitors/convert_format'
2
25
  require 'arel_extensions/visitors/to_sql'
3
26
  require 'arel_extensions/visitors/mysql'
27
+ require 'arel_extensions/visitors/mssql'
4
28
  require 'arel_extensions/visitors/postgresql'
5
29
  require 'arel_extensions/visitors/sqlite'
6
30
 
@@ -9,10 +33,6 @@ if defined?(Arel::Visitors::Oracle)
9
33
  require 'arel_extensions/visitors/oracle12'
10
34
  end
11
35
 
12
- if defined?(Arel::Visitors::SQLServer) || defined?(Arel::Visitors::MSSQL)
13
- require 'arel_extensions/visitors/mssql'
14
- end
15
-
16
36
  if defined?(Arel::Visitors::SQLServer)
17
37
  class Arel::Visitors::SQLServer
18
38
  include ArelExtensions::Visitors::MSSQL
@@ -31,22 +51,7 @@ if defined?(Arel::Visitors::MSSQL)
31
51
  class Arel::Visitors::MSSQL
32
52
  include ArelExtensions::Visitors::MSSQL
33
53
 
34
- alias_method(:old_visit_Arel_Nodes_As, :visit_Arel_Nodes_As) rescue nil
35
- def visit_Arel_Nodes_As o, collector
36
- if o.left.is_a?(Arel::Nodes::Binary)
37
- collector << '('
38
- collector = visit o.left, collector
39
- collector << ')'
40
- else
41
- collector = visit o.left, collector
42
- end
43
- collector << ' AS ['
44
- collector = visit o.right, collector
45
- collector << ']'
46
- collector
47
- end
48
-
49
- alias_method(:old_visit_Arel_Nodes_SelectStatement, :visit_Arel_Nodes_SelectStatement) rescue nil
54
+ alias_method(:old_visit_Arel_Nodes_SelectStatement, :visit_Arel_Nodes_SelectStatement)
50
55
  def visit_Arel_Nodes_SelectStatement o, collector
51
56
  if !collector.value.blank? && o.limit.blank? && o.offset.blank?
52
57
  o = o.dup
@@ -55,51 +60,41 @@ if defined?(Arel::Visitors::MSSQL)
55
60
  old_visit_Arel_Nodes_SelectStatement(o, collector)
56
61
  end
57
62
  end
63
+ end
58
64
 
59
- begin
60
- require 'arel_sqlserver'
61
- if Arel::VERSION.to_i == 6
62
- if Arel::Visitors::VISITORS['sqlserver'] && Arel::Visitors::VISITORS['sqlserver'] != Arel::Visitors::MSSQL
63
- Arel::Visitors::VISITORS['sqlserver'].class_eval do
64
- include ArelExtensions::Visitors::MSSQL
65
-
66
- alias_method(:old_visit_Arel_Nodes_SelectStatement, :visit_Arel_Nodes_SelectStatement) rescue nil
67
- def visit_Arel_Nodes_SelectStatement o, collector
68
- if !collector.value.blank? && o.limit.blank? && o.offset.blank?
69
- o = o.dup
70
- o.orders = []
71
- end
72
- old_visit_Arel_Nodes_SelectStatement(o, collector)
73
- end
74
-
75
- alias_method(:old_visit_Arel_Nodes_As, :visit_Arel_Nodes_As) rescue nil
76
- def visit_Arel_Nodes_As o, collector
77
- if o.left.is_a?(Arel::Nodes::Binary)
78
- collector << '('
79
- collector = visit o.left, collector
80
- collector << ')'
81
- else
82
- collector = visit o.left, collector
83
- end
84
- collector << ' AS ['
85
- collector = visit o.right, collector
86
- collector << ']'
87
- collector
88
- end
65
+ if defined?(Arel::Visitors::SQLServer)
66
+ class Arel::Visitors::SQLServer
67
+ include ArelExtensions::Visitors::MSSQL
89
68
 
90
- alias_method(:old_primary_Key_From_Table, :primary_Key_From_Table) rescue nil
91
- def primary_Key_From_Table t
92
- return unless t
69
+ # There's a bug when working with jruby 9.4 that prevents us from
70
+ # refactoring this and putting it in the main module, or even in a separate
71
+ # module then including it.
72
+ #
73
+ # Reason: the line in this file that does:
74
+ #
75
+ # require 'arel_extensions/visitors/mssql'
76
+ #
77
+ # The error could be seen by:
78
+ #
79
+ # 1. placing the visit_ inside the visitor, or placing it in a module
80
+ # then including it here.
81
+ # 2. replacing the `rescue nil` from aliasing trick, and printing the
82
+ # error.
83
+ #
84
+ # It complains that the visit_ does not exist in the module, as if it's
85
+ # evaluating the module eagerly, instead of lazily like in other versions
86
+ # of ruby.
87
+ #
88
+ # It might be something different, but this is the first thing we should
89
+ # investigate.
93
90
 
94
- column_name = @connection.schema_cache.primary_keys(t.name) ||
95
- @connection.schema_cache.columns_hash(t.name).first.try(:second).try(:name)
96
- column_name ? t[column_name] : nil
97
- end
98
- end
91
+ alias_method(:old_visit_Arel_Nodes_SelectStatement, :visit_Arel_Nodes_SelectStatement) rescue nil
92
+ def visit_Arel_Nodes_SelectStatement o, collector
93
+ if !collector.value.blank? && o.limit.blank? && o.offset.blank?
94
+ o = o.dup
95
+ o.orders = []
99
96
  end
97
+ old_visit_Arel_Nodes_SelectStatement(o, collector)
100
98
  end
101
- rescue LoadError
102
- rescue => e
103
- e
104
99
  end
105
100
  end
@@ -12,7 +12,8 @@ end
12
12
 
13
13
  YELLOW = '33'
14
14
 
15
- # Load gems specific to databases
15
+ # Load gems specific to databases.
16
+ #
16
17
  # NOTE:
17
18
  # It's strongly advised to test each database on its own. Loading multiple
18
19
  # backend gems leads to undefined behavior according to tests; the backend
@@ -22,26 +23,32 @@ YELLOW = '33'
22
23
  # The issue also seems to be related to arel version: at some point, arel
23
24
  # dropped its wide support for DBs and kept Postgres, MySQL and SQLite.
24
25
  # Here, we're just trying to load the correct ones.
26
+ #
27
+ # NOTE:
28
+ # As of jruby 9.4 (and maybe 9.3, but I couldn't test it given the state of
29
+ # the alt-adapter), we need to load jdbc/mssql manually.
25
30
  db_and_gem =
26
- if RUBY_ENGINE == 'jruby'
31
+ if RUBY_PLATFORM == 'java'
27
32
  {
28
- 'oracle' => 'activerecord-oracle_enhanced-adapter',
29
- 'mssql' => 'activerecord-jdbcsqlserver-adapter'
33
+ 'oracle' => ['activerecord-oracle_enhanced-adapter'],
34
+ 'mssql' => ['jdbc/mssql', 'activerecord-jdbcsqlserver-adapter'],
30
35
  }
31
36
  else
32
37
  {
33
- 'oracle' => 'activerecord-oracle_enhanced-adapter',
34
- 'mssql' => 'activerecord-sqlserver-adapter'
38
+ 'oracle' => ['activerecord-oracle_enhanced-adapter'],
39
+ 'mssql' => ['activerecord-sqlserver-adapter'],
35
40
  }
36
41
  end
37
42
 
38
- def load_lib(gem)
39
- if gem && (RUBY_ENGINE == 'jruby' || Arel::VERSION.to_i > 9)
40
- begin
41
- Gem::Specification.find_by_name(gem)
42
- require gem
43
- rescue Gem::MissingSpecError
44
- warn "Warning: failed to load gem #{gem}. Are you sure it's installed?"
43
+ def load_lib(gems)
44
+ if gems && (RUBY_PLATFORM == 'java' || Arel::VERSION.to_i > 9)
45
+ gems.each do |gem|
46
+ begin
47
+ require gem
48
+ rescue Exception => e
49
+ warn "Warning: failed to load gem #{gem}. Are you sure it's installed?"
50
+ warn e.message
51
+ end
45
52
  end
46
53
  end
47
54
  end
data/test/real_db_test.rb CHANGED
@@ -40,6 +40,7 @@ def setup_db
40
40
  t.column :created_at, :date
41
41
  t.column :updated_at, :date
42
42
  t.column :score, :decimal
43
+ t.column :updated_at, :datetime
43
44
  end
44
45
  end
45
46
 
@@ -53,11 +54,12 @@ end
53
54
  class ListTest < Minitest::Test
54
55
  def setup
55
56
  d = Date.new(2016, 05, 23)
57
+ dt = Time.new(2016, 05, 23, 12, 34, 56)
56
58
  setup_db
57
59
  User.create age: 5, name: 'Lucas', created_at: d, score: 20.16
58
60
  User.create age: 15, name: 'Sophie', created_at: d, score: 20.16
59
61
  User.create age: 20, name: 'Camille', created_at: d, score: 20.16
60
- User.create age: 21, name: 'Arthur', created_at: d, score: 65.62
62
+ User.create age: 21, name: 'Arthur', created_at: d, score: 65.62, updated_at: dt
61
63
  u = User.create age: 23, name: 'Myung', created_at: d, score: 20.16
62
64
  @myung = User.where(id: u.id)
63
65
  User.create age: 25, name: 'Laure', created_at: d, score: 20.16
@@ -91,7 +93,7 @@ class ListTest < Minitest::Test
91
93
  end
92
94
  end
93
95
 
94
- def test_Comparator
96
+ def test_comparator
95
97
  assert_equal 2, User.where(User.arel_table[:age] < 6).count
96
98
  assert_equal 2, User.where(User.arel_table[:age] <= 10).count
97
99
  assert_equal 3, User.where(User.arel_table[:age] > 20).count
@@ -99,6 +101,18 @@ class ListTest < Minitest::Test
99
101
  assert_equal 1, User.where(User.arel_table[:age] > 5).where(User.arel_table[:age] < 20).count
100
102
  end
101
103
 
104
+ def test_date_date_comparator
105
+ d = Date.new(2016, 05, 24) #after created_at in db
106
+ assert_equal 8, User.where(User.arel_table[:age] < d).count
107
+ assert_equal 0, User.where(User.arel_table[:age] > d).count
108
+ assert_equal 0, User.where(User.arel_table[:age] == d).count
109
+ d = Date.new(2016, 05, 23)
110
+ assert_equal 8, User.where(User.arel_table[:age] == d).count
111
+ dt = Time.new(2016, 05, 23, 12, 35, 00) #after updated_at in db
112
+ assert_equal 1, User.where(User.arel_table[:update_at] < dt).count
113
+ assert_equal 0, User.where(User.arel_table[:update_at] > dt).count
114
+ end
115
+
102
116
  def test_date_duration
103
117
  # Year
104
118
  assert_equal 2016, User.where(User.arel_table[:name].eq('Lucas')).select((User.arel_table[:created_at].year).as('res')).first.res.to_i
data/version_v1.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = '1.3.9'.freeze
2
+ VERSION = '1.3.11'.freeze
3
3
  end
data/version_v2.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = '2.1.9'.freeze
2
+ VERSION = '2.1.11'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arel_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.9
4
+ version: 1.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yann Azoury
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-05-06 00:00:00.000000000 Z
13
+ date: 2024-08-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: arel