arel_extensions 2.3.3 → 2.4.0

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +92 -43
  3. data/.rubocop.yml +4 -4
  4. data/Makefile +18 -0
  5. data/NEWS.md +7 -0
  6. data/README.md +21 -3
  7. data/dev/arelx.dockerfile +13 -16
  8. data/dev/compose.yaml +26 -28
  9. data/gemfiles/rails8.gemfile +40 -0
  10. data/gemfiles/rails8_1.gemfile +41 -0
  11. data/lib/arel_extensions/constants.rb +13 -0
  12. data/lib/arel_extensions/helpers.rb +3 -4
  13. data/lib/arel_extensions/math_functions.rb +1 -1
  14. data/lib/arel_extensions/nodes/byte_size.rb +11 -0
  15. data/lib/arel_extensions/nodes/case.rb +1 -1
  16. data/lib/arel_extensions/nodes/char_length.rb +11 -0
  17. data/lib/arel_extensions/nodes/function.rb +1 -3
  18. data/lib/arel_extensions/nodes/matches.rb +2 -2
  19. data/lib/arel_extensions/predications.rb +1 -1
  20. data/lib/arel_extensions/string_functions.rb +11 -1
  21. data/lib/arel_extensions/version.rb +1 -1
  22. data/lib/arel_extensions/visitors/mssql.rb +23 -8
  23. data/lib/arel_extensions/visitors/mysql.rb +14 -0
  24. data/lib/arel_extensions/visitors/oracle.rb +15 -1
  25. data/lib/arel_extensions/visitors/postgresql.rb +14 -0
  26. data/lib/arel_extensions/visitors/sqlite.rb +17 -1
  27. data/lib/arel_extensions/visitors/to_sql.rb +1 -1
  28. data/lib/arel_extensions/visitors.rb +1 -1
  29. data/lib/arel_extensions.rb +15 -6
  30. data/test/arelx_test_helper.rb +8 -6
  31. data/test/config_loader.rb +9 -0
  32. data/test/database.yml +8 -6
  33. data/test/real_db_test.rb +2 -2
  34. data/test/support/fake_record.rb +3 -1
  35. data/test/visitors/test_bulk_insert_oracle.rb +2 -2
  36. data/test/visitors/test_bulk_insert_sqlite.rb +2 -2
  37. data/test/with_ar/all_agnostic_test.rb +65 -17
  38. data/test/with_ar/insert_agnostic_test.rb +2 -2
  39. data/test/with_ar/test_bulk_sqlite.rb +2 -2
  40. data/test/with_ar/test_math_sqlite.rb +2 -2
  41. data/test/with_ar/test_string_mysql.rb +2 -2
  42. data/test/with_ar/test_string_sqlite.rb +2 -2
  43. data/version_v1.rb +1 -1
  44. data/version_v2.rb +1 -1
  45. metadata +9 -5
  46. data/bin/compose +0 -6
  47. data/gemfiles/rails3.gemfile +0 -20
  48. data/gemfiles/rails4_2.gemfile +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2117a2b819da1a1699428d490c507dbd426fae75cfe135c07dc77dd92889fe64
4
- data.tar.gz: c822dbd22779954cccd01a0915c2ccd88340d7dca8e44fc4883036268f154947
3
+ metadata.gz: ef0f2b58cbe47227a084eb558fae3debe53e40c84fdad659f87dd3a2a6dd9051
4
+ data.tar.gz: e360d200dcbfdeb2b05f87b7b9e578d6d8710112e9f16371ecfc4c438dd078d4
5
5
  SHA512:
6
- metadata.gz: a003802df5fa1bf4ed39562f679deeb3675f9771d14693a740a0374631e311a7ba25d6418f8161b1042e413ab7a71b3b283757b20d903ba0061734d12a14481c
7
- data.tar.gz: 413005a75a63ff2a6e6c72e75ccff060b2c6d3698725a561541b3b981400a48f1840fb1d762f02fd07b453df2107acbefe465a75e5e07c4503d458d444381e8f
6
+ metadata.gz: c1020a652427f790d4de92c290ec7ea69512b8ef361675e0598260dbe457b6eab17500466c7bed788f24fc531f9bc39e64a7c3dcab28634409da8bfece3b98f0
7
+ data.tar.gz: 874ce5525d4ea992a55808e1f6b1f73560d4fa4f17807ba04608d0e1f4abe46d49c6c65fc3f7580c881e001b7c456d823f7a666d6a9089585ffd67dac4d94add
@@ -24,10 +24,20 @@ jobs:
24
24
  matrix:
25
25
  versions:
26
26
  [
27
+ { ruby: "3.4", rails: 8_1, arelx: 2 },
28
+ { ruby: "3.4", rails: 8, arelx: 2 },
29
+ { ruby: "3.4", rails: 7_2, arelx: 2 },
30
+ { ruby: "3.4", rails: 7_1, arelx: 2 },
31
+ { ruby: "3.4", rails: 7, arelx: 2 },
32
+ { ruby: "3.4", rails: 6_1, arelx: 2 },
33
+ { ruby: "3.3", rails: 8_1, arelx: 2 },
34
+ { ruby: "3.3", rails: 8, arelx: 2 },
27
35
  { ruby: "3.3", rails: 7_2, arelx: 2 },
28
36
  { ruby: "3.3", rails: 7_1, arelx: 2 },
29
37
  { ruby: "3.3", rails: 7, arelx: 2 },
30
38
  { ruby: "3.3", rails: 6_1, arelx: 2 },
39
+ { ruby: "3.2", rails: 8_1, arelx: 2 },
40
+ { ruby: "3.2", rails: 8, arelx: 2 },
31
41
  { ruby: "3.2", rails: 7_2, arelx: 2 },
32
42
  { ruby: "3.2", rails: 7_1, arelx: 2 },
33
43
  { ruby: "3.2", rails: 7, arelx: 2 },
@@ -46,11 +56,6 @@ jobs:
46
56
  { ruby: "2.7", rails: 6_1, arelx: 2 },
47
57
  { ruby: "2.7", rails: 6, arelx: 2 },
48
58
  { ruby: "2.7", rails: 5_2, arelx: 1 },
49
- { ruby: "2.7", rails: 4_2, arelx: 1 },
50
- { ruby: "2.5", rails: 6_1, arelx: 2 },
51
- { ruby: "2.5", rails: 6, arelx: 2 },
52
- { ruby: "2.5", rails: 5_2, arelx: 1 },
53
- { ruby: "2.5", rails: 4_2, arelx: 1 },
54
59
  { ruby: jruby-9.2, rails: 6_1, arelx: 2 },
55
60
  { ruby: jruby-9.2, rails: 6, arelx: 2 },
56
61
  { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
@@ -88,10 +93,20 @@ jobs:
88
93
  matrix:
89
94
  versions:
90
95
  [
96
+ { ruby: "3.4", rails: 8_1, arelx: 2 },
97
+ { ruby: "3.4", rails: 8, arelx: 2 },
98
+ { ruby: "3.4", rails: 7_2, arelx: 2 },
99
+ { ruby: "3.4", rails: 7_1, arelx: 2 },
100
+ { ruby: "3.4", rails: 7, arelx: 2 },
101
+ { ruby: "3.4", rails: 6_1, arelx: 2 },
102
+ { ruby: "3.3", rails: 8_1, arelx: 2 },
103
+ { ruby: "3.3", rails: 8, arelx: 2 },
91
104
  { ruby: "3.3", rails: 7_2, arelx: 2 },
92
105
  { ruby: "3.3", rails: 7_1, arelx: 2 },
93
106
  { ruby: "3.3", rails: 7, arelx: 2 },
94
107
  { ruby: "3.3", rails: 6_1, arelx: 2 },
108
+ { ruby: "3.2", rails: 8_1, arelx: 2 },
109
+ { ruby: "3.2", rails: 8, arelx: 2 },
95
110
  { ruby: "3.2", rails: 7_2, arelx: 2 },
96
111
  { ruby: "3.2", rails: 7_1, arelx: 2 },
97
112
  { ruby: "3.2", rails: 7, arelx: 2 },
@@ -110,15 +125,9 @@ jobs:
110
125
  { ruby: "2.7", rails: 6_1, arelx: 2 },
111
126
  { ruby: "2.7", rails: 6, arelx: 2 },
112
127
  { ruby: "2.7", rails: 5_2, arelx: 1 },
113
- { ruby: "2.7", rails: 4_2, arelx: 1 },
114
- { ruby: "2.5", rails: 6_1, arelx: 2 },
115
- { ruby: "2.5", rails: 6, arelx: 2 },
116
- { ruby: "2.5", rails: 5_2, arelx: 1 },
117
- { ruby: "2.5", rails: 4_2, arelx: 1 },
118
128
  { ruby: jruby-9.2, rails: 6_1, arelx: 2 },
119
129
  { ruby: jruby-9.2, rails: 6, arelx: 2 },
120
130
  { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
121
- { ruby: jruby-9.2, rails: 4_2, arelx: 1 },
122
131
  { ruby: jruby-9.3, rails: 6_1, arelx: 2 },
123
132
  { ruby: jruby-9.3, rails: 6, arelx: 2 },
124
133
  { ruby: jruby-9.3, rails: 5_2, arelx: 1 },
@@ -152,10 +161,20 @@ jobs:
152
161
  fail-fast: false
153
162
  matrix:
154
163
  versions: [
164
+ { ruby: "3.4", rails: 8_1, arelx: 2 },
165
+ { ruby: "3.4", rails: 8, arelx: 2 },
166
+ { ruby: "3.4", rails: 7_2, arelx: 2 },
167
+ { ruby: "3.4", rails: 7_1, arelx: 2 },
168
+ { ruby: "3.4", rails: 7, arelx: 2 },
169
+ { ruby: "3.4", rails: 6_1, arelx: 2 },
170
+ { ruby: "3.3", rails: 8_1, arelx: 2 },
171
+ { ruby: "3.3", rails: 8, arelx: 2 },
155
172
  { ruby: "3.3", rails: 7_2, arelx: 2 },
156
173
  { ruby: "3.3", rails: 7_1, arelx: 2 },
157
174
  { ruby: "3.3", rails: 7, arelx: 2 },
158
175
  { ruby: "3.3", rails: 6_1, arelx: 2 },
176
+ { ruby: "3.2", rails: 8_1, arelx: 2 },
177
+ { ruby: "3.2", rails: 8, arelx: 2 },
159
178
  { ruby: "3.2", rails: 7_2, arelx: 2 },
160
179
  { ruby: "3.2", rails: 7_1, arelx: 2 },
161
180
  { ruby: "3.2", rails: 7, arelx: 2 },
@@ -174,15 +193,9 @@ jobs:
174
193
  { ruby: "2.7", rails: 6_1, arelx: 2 },
175
194
  { ruby: "2.7", rails: 6, arelx: 2 },
176
195
  { ruby: "2.7", rails: 5_2, arelx: 1 },
177
- { ruby: "2.7", rails: 4_2, arelx: 1 },
178
- { ruby: "2.5", rails: 6_1, arelx: 2 },
179
- { ruby: "2.5", rails: 6, arelx: 2 },
180
- { ruby: "2.5", rails: 5_2, arelx: 1 },
181
- { ruby: "2.5", rails: 4_2, arelx: 1 },
182
196
  { ruby: jruby-9.2, rails: 6_1, arelx: 2 },
183
197
  { ruby: jruby-9.2, rails: 6, arelx: 2 },
184
198
  { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
185
- { ruby: jruby-9.2, rails: 4_2, arelx: 1 },
186
199
  { ruby: jruby-9.3, rails: 6_1, arelx: 2 },
187
200
  { ruby: jruby-9.3, rails: 6, arelx: 2 },
188
201
  { ruby: jruby-9.3, rails: 5_2, arelx: 1 },
@@ -241,10 +254,20 @@ jobs:
241
254
  fail-fast: false
242
255
  matrix:
243
256
  versions: [
257
+ { ruby: "3.4", rails: 8_1, arelx: 2 },
258
+ { ruby: "3.4", rails: 8, arelx: 2 },
259
+ { ruby: "3.4", rails: 7_2, arelx: 2 },
260
+ { ruby: "3.4", rails: 7_1, arelx: 2 },
261
+ { ruby: "3.4", rails: 7, arelx: 2 },
262
+ { ruby: "3.4", rails: 6_1, arelx: 2 },
263
+ { ruby: "3.3", rails: 8_1, arelx: 2 },
264
+ { ruby: "3.3", rails: 8, arelx: 2 },
244
265
  { ruby: "3.3", rails: 7_2, arelx: 2 },
245
266
  { ruby: "3.3", rails: 7_1, arelx: 2 },
246
267
  { ruby: "3.3", rails: 7, arelx: 2 },
247
268
  { ruby: "3.3", rails: 6_1, arelx: 2 },
269
+ { ruby: "3.2", rails: 8_1, arelx: 2 },
270
+ { ruby: "3.2", rails: 8, arelx: 2 },
248
271
  { ruby: "3.2", rails: 7_2, arelx: 2 },
249
272
  { ruby: "3.2", rails: 7_1, arelx: 2 },
250
273
  { ruby: "3.2", rails: 7, arelx: 2 },
@@ -263,35 +286,56 @@ jobs:
263
286
  { ruby: "2.7", rails: 6_1, arelx: 2 },
264
287
  { ruby: "2.7", rails: 6, arelx: 2 },
265
288
  { ruby: "2.7", rails: 5_2, arelx: 1 },
266
- { ruby: "2.7", rails: 4_2, arelx: 1 },
267
- { ruby: "2.5", rails: 6_1, arelx: 2 },
268
- { ruby: "2.5", rails: 6, arelx: 2 },
269
- { ruby: "2.5", rails: 5_2, arelx: 1 },
270
- { ruby: "2.5", rails: 4_2, arelx: 1 },
271
289
  { ruby: jruby-9.2, rails: 6_1, arelx: 2 },
272
290
  { ruby: jruby-9.2, rails: 6, arelx: 2 },
273
291
  { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
274
- { ruby: jruby-9.2, rails: 4_2, arelx: 1 },
275
292
  { ruby: jruby-9.3, rails: 6_1, arelx: 2 },
276
293
  { ruby: jruby-9.3, rails: 6, arelx: 2 },
277
294
  { ruby: jruby-9.3, rails: 5_2, arelx: 1 },
278
295
  ]
279
- services:
280
- mysql:
281
- image: mysql:5.7
282
- env:
283
- MYSQL_ALLOW_EMPTY_PASSWORD: true
284
- MYSQL_USERNAME: root
285
- MYSQL_DATABASE: arelx_test
286
- ports:
287
- - 3306:3306
288
- options: >-
289
- --health-cmd="mysqladmin ping"
290
- --health-interval=10s
291
- --health-timeout=5s
292
- --health-retries=3
296
+ # TODO: restore the service. it's far simpler, but since we're testing old
297
+ # mysql, and we want utf-8 by default, we're currently forced to avoid the
298
+ # service, and do it as a step. Maybe there's a better solution, who knows?
299
+ #
300
+ # services:
301
+ # mysql:
302
+ # image: mysql:5.7
303
+ # env:
304
+ # MYSQL_ALLOW_EMPTY_PASSWORD: true
305
+ # MYSQL_USERNAME: root
306
+ # MYSQL_DATABASE: arelx_test
307
+ # ports:
308
+ # - 3306:3306
309
+ # options: >-
310
+ # --health-cmd="mysqladmin ping"
311
+ # --health-interval=10s
312
+ # --health-timeout=5s
313
+ # --health-retries=3
314
+ #
293
315
  steps:
294
316
  - uses: actions/checkout@v2
317
+
318
+ - name: Start MySQL with UTF-8
319
+ run: |
320
+ docker run -d \
321
+ --name mysql \
322
+ -e MYSQL_ALLOW_EMPTY_PASSWORD=true \
323
+ -e MYSQL_DATABASE=arelx_test \
324
+ -p 3306:3306 \
325
+ --health-cmd="mysqladmin ping" \
326
+ --health-interval=10s \
327
+ --health-timeout=5s \
328
+ --health-retries=3 \
329
+ mysql:5.7 \
330
+ --character-set-server=utf8mb4
331
+
332
+ - name: Wait for MySQL
333
+ run: |
334
+ until docker exec mysql mysqladmin ping --silent; do
335
+ echo 'Waiting for MySQL...'
336
+ sleep 2
337
+ done
338
+
295
339
  - name: Set up Ruby
296
340
  uses: ruby/setup-ruby@v1
297
341
  with:
@@ -325,10 +369,21 @@ jobs:
325
369
  fail-fast: false
326
370
  matrix:
327
371
  versions: [
372
+ { ruby: "3.4", rails: 8_1, arelx: 2 },
373
+ { ruby: "3.4", rails: 8, arelx: 2 },
374
+ { ruby: "3.4", rails: 7_2, arelx: 2 },
375
+ { ruby: "3.4", rails: 7_1, arelx: 2 },
376
+ { ruby: "3.4", rails: 7, arelx: 2 },
377
+ { ruby: "3.4", rails: 6_1, arelx: 2 },
378
+ { ruby: "3.3", rails: 8_1, arelx: 2 },
379
+ { ruby: "3.3", rails: 8, arelx: 2 },
380
+ { ruby: "3.3", rails: 7_2, arelx: 2 },
328
381
  { ruby: "3.3", rails: 7_1, arelx: 2 },
329
382
  { ruby: "3.3", rails: 7, arelx: 2 },
330
383
  { ruby: "3.3", rails: 6_1, arelx: 2 },
331
384
  { ruby: "3.3", rails: 6, arelx: 2 },
385
+ { ruby: "3.2", rails: 8_1, arelx: 2 },
386
+ { ruby: "3.2", rails: 8, arelx: 2 },
332
387
  { ruby: "3.2", rails: 7_1, arelx: 2 },
333
388
  { ruby: "3.2", rails: 7, arelx: 2 },
334
389
  { ruby: "3.2", rails: 6_1, arelx: 2 },
@@ -343,15 +398,9 @@ jobs:
343
398
  { ruby: "2.7", rails: 6_1, arelx: 2 },
344
399
  { ruby: "2.7", rails: 6, arelx: 2 },
345
400
  { ruby: "2.7", rails: 5_2, arelx: 1 },
346
- { ruby: "2.7", rails: 4_2, arelx: 1 },
347
- { ruby: "2.5", rails: 6_1, arelx: 2 },
348
- { ruby: "2.5", rails: 6, arelx: 2 },
349
- { ruby: "2.5", rails: 5_2, arelx: 1 },
350
- { ruby: "2.5", rails: 4_2, arelx: 1 },
351
401
  # {ruby: jruby-9.2, rails: 6_1, arelx: 2},
352
402
  # {ruby: jruby-9.2, rails: 6, arelx: 2},
353
403
  { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
354
- { ruby: jruby-9.2, rails: 4_2, arelx: 1 },
355
404
  # See comments on 9.4 to understand why these are disabled for now.
356
405
  # {ruby: jruby-9.3, rails: 6_1, arelx: 2},
357
406
  # {ruby: jruby-9.3, rails: 6, arelx: 2},
data/.rubocop.yml CHANGED
@@ -1,7 +1,10 @@
1
+ plugins:
2
+ - rubocop-performance
3
+
1
4
  AllCops:
2
5
  DisabledByDefault: true
3
6
  Exclude:
4
- - "vendor/**/*"
7
+ - "vendor/**/*"
5
8
 
6
9
  Layout/EndOfLine:
7
10
  Enabled: true
@@ -94,9 +97,6 @@ Style/SymbolArray:
94
97
  Style/WordArray:
95
98
  Enabled: true
96
99
 
97
- # Performance cops have been transferred to rubocop-performance gem.
98
- require: rubocop-performance
99
-
100
100
  Performance/DoubleStartEndWith:
101
101
  Enabled: true
102
102
 
data/Makefile ADDED
@@ -0,0 +1,18 @@
1
+ COMPOSE_FILE := dev/compose.yaml
2
+ DC := docker compose -f $(COMPOSE_FILE)
3
+
4
+ .PHONY: down rebuild shell up
5
+
6
+ down:
7
+ $(DC) down
8
+
9
+ rebuild:
10
+ $(DC) build --no-cache
11
+
12
+ # Jump into the container
13
+ shell: up
14
+ $(DC) exec arelx bash
15
+
16
+ # Boot everything and keep it running (daemon mode)
17
+ up:
18
+ $(DC) up -d
data/NEWS.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## [unreleased]
4
4
 
5
+ ## Release v2.4.0/v1.6.0 (23-12-2025)
6
+
7
+ - Drop supoprt for Ruby < 2.7.
8
+ - Drop support for Rails < 5.2.
9
+ - Add support for Rails 8 and 8.1.
10
+ - Add `byte_size` and `char_length`. They should replace all uses of `length` because it's inconsistent across vendors; it can surprise you and give you byte size when you expect string length.
11
+
5
12
  ## Release v2.3.3/v1.5.3 (11-02-2025)
6
13
 
7
14
  - Fix the `&` operator which does `find_in_set` for mysql and postgres, accepting strings and integers.
data/README.md CHANGED
@@ -31,7 +31,7 @@ Most of the features will work just by adding the gem to your Gemfiles. To make
31
31
  ArelExtensions::CommonSqlFunctions.new(ActiveRecord::Base.connection).add_sql_functions()
32
32
  ```
33
33
 
34
- It will add common SQL features in your DB to align ti with current routines. Technically, it will execute SQL scripts from init folder.
34
+ It will add common SQL features in your DB to align it with current routines. Technically, it will execute SQL scripts from init folder.
35
35
 
36
36
 
37
37
  ## Examples
@@ -195,7 +195,7 @@ by the RDBMS.
195
195
  Warning:
196
196
 
197
197
  - ⚠️ Time Zone names are specific to each RDBMS. While `PostgreSQL` and `MySQL`
198
- have overlaping names (the ones prefixed with `posix`), you should always
198
+ have overlapping names (the ones prefixed with `posix`), you should always
199
199
  read your vendor's documentation. `SQL Server` is a black sheep and has its
200
200
  own conventions.
201
201
  - ⚠️ Daylight saving is managed by the RDBMS vendor. Choose the approptiate time
@@ -373,7 +373,25 @@ User.connection.execute(insert_manager.to_sql)
373
373
  <td class="tg-j6lv">LOWER() LIKE LOWER()</td>
374
374
  </tr>
375
375
  <tr>
376
- <td class="tg-yw4l">LENGTH<br>column.length</td>
376
+ <td class="tg-yw4l">LENGTH<br>column.char_length</td>
377
+ <td class="ok">✔</td>
378
+ <td class="ok">✔</td>
379
+ <td class="ok">✔</td>
380
+ <td class="ok">✔</td>
381
+ <td class="tg-j6lv">✔</td>
382
+ <td class="ok">not implemented</td>
383
+ </tr>
384
+ <tr>
385
+ <td class="tg-yw4l">LENGTH (aka octet_length)<br>column.byte_size</td>
386
+ <td class="ok">✔</td>
387
+ <td class="ok">✔</td>
388
+ <td class="ok">✔</td>
389
+ <td class="ok">✔</td>
390
+ <td class="tg-j6lv">✔</td>
391
+ <td class="ok">not implemented</td>
392
+ </tr>
393
+ <tr>
394
+ <td class="tg-yw4l">LENGTH<br>column.length<br>⚠️ not portable, prefer char_length or byte_size</td>
377
395
  <td class="ok">✔</td>
378
396
  <td class="ok">✔</td>
379
397
  <td class="ok">✔</td>
data/dev/arelx.dockerfile CHANGED
@@ -1,27 +1,26 @@
1
1
  FROM ubuntu:22.04
2
2
 
3
- ENV RBENV_ROOT=/opt/rbenv
4
- ENV PATH=${RBENV_ROOT}/shims:${RBENV_ROOT}/bin:${PATH}
5
3
  ENV APP_HOME=/app
6
- # I know there's a more reliable way, but this is simpler.
7
- ENV IN_DOCKER=true
8
4
  ENV DEBIAN_FRONTEND=noninteractive
9
5
 
10
6
  RUN mkdir -p $APP_HOME
11
7
 
8
+ # Install OS dependencies
12
9
  RUN apt-get update -q && apt-get install -y \
13
10
  curl bundler build-essential git gnupg locales \
14
11
  libbz2-dev libffi-dev liblzma-dev lsb-release libsqlite3-dev libyaml-dev \
15
- make openjdk-17-jdk-headless ruby-dev ruby-full tzdata zlib1g-dev \
12
+ make neovim ncurses-term openjdk-17-jdk-headless tzdata zlib1g-dev \
16
13
  && ln -fs /usr/share/zoneinfo/UTC /etc/localtime \
17
14
  && dpkg-reconfigure --frontend noninteractive tzdata
18
15
 
16
+ # Add DB Repo Keys
19
17
  RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg \
20
18
  && echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list \
21
19
  && curl https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.asc \
22
20
  && curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | tee /etc/apt/sources.list.d/mssql-release.list \
23
21
  && apt-get update -q
24
22
 
23
+ # Install DB Clients
25
24
  RUN ACCEPT_EULA=y DEBIAN_FRONTEND=noninteractive apt-get install -y \
26
25
  freetds-dev libmysqlclient-dev mysql-client msodbcsql18 mssql-tools18 unixodbc-dev libpq-dev \
27
26
  && echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc \
@@ -29,16 +28,14 @@ RUN ACCEPT_EULA=y DEBIAN_FRONTEND=noninteractive apt-get install -y \
29
28
  && rm -rf /var/lib/apt/lists/* \
30
29
  && locale-gen en_US.UTF-8
31
30
 
32
- RUN /bin/bash -c "source ~/.bashrc"
31
+ WORKDIR $APP_HOME
33
32
 
34
- RUN mkdir -p ${RBENV_ROOT} \
35
- && git clone https://github.com/rbenv/rbenv.git ${RBENV_ROOT} \
36
- && git clone --depth 1 https://github.com/rbenv/ruby-build.git ${RBENV_ROOT}/plugins/ruby-build \
37
- && rbenv init - \
38
- && rbenv global system
33
+ # Install Ruby via Mise
34
+ ENV MISE_DATA_DIR="/mise"
35
+ ENV MISE_CONFIG_DIR="/mise"
36
+ ENV MISE_CACHE_DIR="/mise/cache"
37
+ ENV MISE_INSTALL_PATH="/usr/local/bin/mise"
38
+ ENV PATH="/mise/shims:$PATH"
39
39
 
40
- WORKDIR $APP_HOME
41
- COPY ./dev/rbenv ./dev/rbenv
42
- COPY ./.github/workflows/ruby.yml ./.github/workflows/ruby.yml
43
- RUN /usr/bin/gem install colorize psych toml-rb
44
- RUN ./dev/rbenv install && rm ./dev/rbenv ./.github/workflows/ruby.yml
40
+ RUN curl https://mise.run | sh
41
+ RUN mise install ruby
data/dev/compose.yaml CHANGED
@@ -7,29 +7,34 @@ services:
7
7
  dockerfile: dev/arelx.dockerfile
8
8
  volumes:
9
9
  - ../:/app
10
- entrypoint: ["/usr/bin/ruby", "dev/rbenv", "test"]
11
- network_mode: "host"
10
+ - gem_cache:/mise/installs/ruby
11
+ command: tail -f /dev/null
12
12
  depends_on:
13
13
  mariadb:
14
14
  condition: service_healthy
15
15
  postgres:
16
16
  condition: service_healthy
17
- mssql:
18
- condition: service_healthy
17
+ # TODO: Fix, it's not healthy apparently
18
+ # mssql:
19
+ # condition: service_healthy
20
+ environment:
21
+ # Map ENV vars for database.yml
22
+ MYSQL_HOST: mariadb
23
+ POSTGRES_HOST: postgres
24
+ MSSQL_HOST: mssql
25
+
19
26
  mariadb:
20
27
  image: mariadb:11.0
21
28
  container_name: mariadb
22
29
  environment:
23
30
  MARIADB_DATABASE: arelx_test
24
31
  MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: true
25
- ports:
26
- - "3306:3306"
27
- network_mode: "host"
28
32
  healthcheck:
29
33
  test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
30
- interval: 10s
34
+ interval: 5s
31
35
  timeout: 5s
32
- retries: 3
36
+ retries: 5
37
+
33
38
  postgres:
34
39
  build:
35
40
  context: ..
@@ -39,33 +44,26 @@ services:
39
44
  POSTGRES_USER: postgres
40
45
  POSTGRES_PASSWORD: secret
41
46
  POSTGRES_DB: arelx_test
42
- ports:
43
- - "5432:5432"
44
- network_mode: "host"
45
47
  healthcheck:
46
48
  test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
47
- interval: 10s
49
+ interval: 5s
48
50
  timeout: 5s
49
- retries: 3
51
+ retries: 5
52
+
50
53
  mssql:
51
54
  image: mcr.microsoft.com/mssql/server:2019-latest
52
55
  container_name: mssql
56
+ platform: linux/amd64
53
57
  environment:
54
- MSSQL_SA_PASSWORD: Password12!
55
58
  ACCEPT_EULA: Y
56
- ports:
57
- - "1433:1433"
58
- network_mode: "host"
59
+ # MSSQL_COLLATION: Latin1_General_100_CI_AS_SC_UTF8
60
+ MSSQL_SA_PASSWORD: Password12!
59
61
  healthcheck:
60
- test:
61
- [
62
- "CMD-SHELL",
63
- "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $${MSSQL_SA_PASSWORD} -Q 'SELECT 1'",
64
- ]
65
- interval: 30s
66
- retries: 5
62
+ test: ["CMD-SHELL", "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $${MSSQL_SA_PASSWORD} -Q 'SELECT 1'"]
63
+ interval: 10s
64
+ retries: 20
65
+ start_period: 30s
67
66
  timeout: 10s
68
67
 
69
- networks:
70
- default:
71
- name: arelx-network
68
+ volumes:
69
+ gem_cache:
@@ -0,0 +1,40 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '~> 8.0'
4
+
5
+ group :development, :test do
6
+ gem 'ruby-lsp', platforms: %i[mri]
7
+ gem 'debug', platforms: %i[mri]
8
+
9
+ gem 'activesupport', '~> 8.0'
10
+ gem 'activemodel', '~> 8.0'
11
+ gem 'activerecord', '~> 8.0'
12
+
13
+ gem 'sqlite3', '~> 2.1', platforms: [:mri]
14
+ gem 'mysql2', '~>0.5', platforms: [:mri]
15
+ gem 'pg', '~> 1.5', platforms: [:mri]
16
+
17
+ gem 'tiny_tds', platforms: %i[mri mingw x64_mingw mswin]
18
+ gem 'activerecord-sqlserver-adapter', '~> 8.0', platforms: %i[mri mingw x64_mingw mswin]
19
+ gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw]
20
+
21
+ gem 'ruby-oci8', platforms: %i[mri mswin mingw] if ENV.has_key? 'ORACLE_HOME'
22
+ gem 'activerecord-oracle_enhanced-adapter', '~> 8.0' if ENV.has_key? 'ORACLE_HOME'
23
+
24
+ # for JRuby
25
+ gem 'jdbc-mssql', platforms: :jruby, require: true
26
+ gem 'jdbc-sqlite3', platform: :jruby
27
+ gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
28
+ gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
29
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
30
+
31
+ # Ruby 3.4+ removes the following gems from the standard distribution.
32
+ # Warnings are emitted from 3.3.
33
+ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('3.3.0')
34
+ gem 'base64'
35
+ gem 'bigdecimal'
36
+ gem 'mutex_m'
37
+ end
38
+ end
39
+
40
+ gemspec path: Dir.pwd
@@ -0,0 +1,41 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '~> 8.1'
4
+
5
+ group :development, :test do
6
+ gem 'ruby-lsp', platforms: %i[mri]
7
+ gem 'debug', platforms: %i[mri]
8
+
9
+ gem 'activesupport', '~> 8.1'
10
+ gem 'activemodel', '~> 8.1'
11
+ gem 'activerecord', '~> 8.1'
12
+
13
+ gem 'sqlite3', '~> 2.1', platforms: [:mri]
14
+ gem 'mysql2', '~>0.5', platforms: [:mri]
15
+ gem 'pg', '~> 1.5', platforms: [:mri]
16
+
17
+ gem 'tiny_tds', platforms: %i[mri mingw x64_mingw mswin]
18
+ gem 'activerecord-sqlserver-adapter', '~> 8.1', platforms: %i[mri mingw x64_mingw mswin]
19
+ gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw]
20
+
21
+ gem 'ruby-oci8', platforms: %i[mri mswin mingw] if ENV.has_key? 'ORACLE_HOME'
22
+ # gem 'activerecord-oracle_enhanced-adapter', '~> 8.1.0' if ENV.has_key? 'ORACLE_HOME'
23
+
24
+ # for JRuby
25
+ gem 'jdbc-mssql', platforms: :jruby, require: true
26
+ gem 'jdbc-sqlite3', platform: :jruby
27
+ # gem 'activerecord-jdbc-alt-adapter', '~> 71.0.0.alpha1', platform: :jruby, require: true
28
+ gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
29
+ gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
30
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
31
+
32
+ # Ruby 3.4+ removes the following gems from the standard distribution.
33
+ # Warnings are emitted from 3.3.
34
+ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('3.3.0')
35
+ gem 'base64'
36
+ gem 'bigdecimal'
37
+ gem 'mutex_m'
38
+ end
39
+ end
40
+
41
+ gemspec path: Dir.pwd
@@ -0,0 +1,13 @@
1
+ module ArelExtensions
2
+ ACTIVE_RECORD_VERSION = Gem::Version.new(ActiveRecord::VERSION::STRING).freeze
3
+ AREL_VERSION = Gem::Version.new(Arel::VERSION).freeze
4
+ V10 = Gem::Version.new('10.0').freeze
5
+ V5 = Gem::Version.new('5.0').freeze
6
+ V6 = Gem::Version.new('6.0').freeze
7
+ V7 = Gem::Version.new('7.0').freeze
8
+ V7_0 = Gem::Version.new('7.0').freeze
9
+ V7_1 = Gem::Version.new('7.1').freeze
10
+ V7_2 = Gem::Version.new('7.2').freeze
11
+ V8_1 = Gem::Version.new('8.1').freeze
12
+ V9_0 = Gem::Version.new('9.0').freeze
13
+ end
@@ -1,5 +1,4 @@
1
1
  module ArelExtensions
2
-
3
2
  #
4
3
  # column_of
5
4
  #
@@ -34,13 +33,13 @@ module ArelExtensions
34
33
  column_of_via_arel_table(table_name, column_name)
35
34
  else
36
35
  if pool.respond_to?(:pool_config)
37
- if pool.pool_config.respond_to?(:schema_reflection) # activerecord >= 7.1
38
- if ActiveRecord.version >= Gem::Version.create('7.2')
36
+ if pool.pool_config.respond_to?(:schema_reflection)
37
+ if ACTIVE_RECORD_VERSION >= V7_2
39
38
  pool.pool_config.schema_reflection.columns_hash(pool, table_name)[column_name]
40
39
  else
41
40
  pool.pool_config.schema_reflection.columns_hash(ActiveRecord::Base.connection, table_name)[column_name]
42
41
  end
43
- else # activerecord < 7.1
42
+ else
44
43
  pool.pool_config.schema_cache.columns_hash(table_name)[column_name]
45
44
  end
46
45
  elsif pool.respond_to?(:schema_cache) # activerecord < 6.1
@@ -71,7 +71,7 @@ module ArelExtensions
71
71
  end
72
72
 
73
73
  def sum opts = {unbiased: true}
74
- if Gem::Version.new(Arel::VERSION) >= Gem::Version.new('9.0.0')
74
+ if AREL_VERSION >= V9_0
75
75
  Arel::Nodes::Sum.new [self]
76
76
  else
77
77
  ArelExtensions::Nodes::Sum.new self, **opts
@@ -0,0 +1,11 @@
1
+ module ArelExtensions
2
+ module Nodes
3
+ class ByteSize < Function
4
+ RETURN_TYPE = :integer
5
+
6
+ def initialize(node)
7
+ super([node])
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,6 +1,6 @@
1
1
  module ArelExtensions
2
2
  module Nodes
3
- if Gem::Version.new(Arel::VERSION) < Gem::Version.new('7.1.0')
3
+ if AREL_VERSION < V7_1
4
4
  class Case < Arel::Nodes::Node
5
5
  include Arel::Expressions
6
6
  include Arel::Math
@@ -0,0 +1,11 @@
1
+ module ArelExtensions
2
+ module Nodes
3
+ class CharLength < Function
4
+ RETURN_TYPE = :integer
5
+
6
+ def initialize(node)
7
+ super([node])
8
+ end
9
+ end
10
+ end
11
+ end