arel_extensions 1.6.0 → 2.0.0.rc3

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 (146) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +2 -1
  3. data/.gitignore +6 -7
  4. data/.rubocop.yml +3 -67
  5. data/.travis/oracle/download.js +152 -0
  6. data/.travis/oracle/download.sh +30 -0
  7. data/.travis/oracle/download_ojdbc.js +116 -0
  8. data/.travis/oracle/install.sh +34 -0
  9. data/.travis/setup_accounts.sh +9 -0
  10. data/.travis/sqlite3/extension-functions.sh +6 -0
  11. data/.travis.yml +223 -0
  12. data/Gemfile +28 -2
  13. data/README.md +91 -258
  14. data/Rakefile +30 -48
  15. data/TODO +1 -0
  16. data/appveyor.yml +22 -60
  17. data/arel_extensions.gemspec +14 -13
  18. data/functions.html +3 -3
  19. data/gemfiles/rails3.gemfile +20 -0
  20. data/gemfiles/rails4.gemfile +29 -0
  21. data/gemfiles/rails5_0.gemfile +29 -0
  22. data/gemfiles/rails5_1_4.gemfile +14 -14
  23. data/gemfiles/rails5_2.gemfile +14 -16
  24. data/init/mssql.sql +4 -4
  25. data/init/mysql.sql +38 -38
  26. data/init/oracle.sql +0 -0
  27. data/init/postgresql.sql +25 -24
  28. data/init/sqlite.sql +0 -0
  29. data/lib/arel_extensions/attributes.rb +3 -7
  30. data/lib/arel_extensions/boolean_functions.rb +14 -53
  31. data/lib/arel_extensions/common_sql_functions.rb +17 -16
  32. data/lib/arel_extensions/comparators.rb +28 -29
  33. data/lib/arel_extensions/date_duration.rb +13 -17
  34. data/lib/arel_extensions/insert_manager.rb +15 -18
  35. data/lib/arel_extensions/math.rb +53 -55
  36. data/lib/arel_extensions/math_functions.rb +39 -46
  37. data/lib/arel_extensions/nodes/abs.rb +1 -0
  38. data/lib/arel_extensions/nodes/blank.rb +2 -1
  39. data/lib/arel_extensions/nodes/case.rb +19 -20
  40. data/lib/arel_extensions/nodes/cast.rb +8 -10
  41. data/lib/arel_extensions/nodes/ceil.rb +1 -1
  42. data/lib/arel_extensions/nodes/coalesce.rb +4 -3
  43. data/lib/arel_extensions/nodes/collate.rb +10 -9
  44. data/lib/arel_extensions/nodes/concat.rb +18 -9
  45. data/lib/arel_extensions/nodes/date_diff.rb +26 -42
  46. data/lib/arel_extensions/nodes/duration.rb +3 -0
  47. data/lib/arel_extensions/nodes/find_in_set.rb +1 -0
  48. data/lib/arel_extensions/nodes/floor.rb +1 -1
  49. data/lib/arel_extensions/nodes/format.rb +8 -35
  50. data/lib/arel_extensions/nodes/formatted_number.rb +23 -22
  51. data/lib/arel_extensions/nodes/function.rb +37 -46
  52. data/lib/arel_extensions/nodes/is_null.rb +0 -0
  53. data/lib/arel_extensions/nodes/json.rb +39 -52
  54. data/lib/arel_extensions/nodes/length.rb +0 -5
  55. data/lib/arel_extensions/nodes/levenshtein_distance.rb +1 -1
  56. data/lib/arel_extensions/nodes/locate.rb +2 -1
  57. data/lib/arel_extensions/nodes/log10.rb +2 -1
  58. data/lib/arel_extensions/nodes/matches.rb +8 -6
  59. data/lib/arel_extensions/nodes/md5.rb +1 -0
  60. data/lib/arel_extensions/nodes/power.rb +5 -5
  61. data/lib/arel_extensions/nodes/rand.rb +1 -0
  62. data/lib/arel_extensions/nodes/repeat.rb +5 -3
  63. data/lib/arel_extensions/nodes/replace.rb +8 -16
  64. data/lib/arel_extensions/nodes/round.rb +6 -5
  65. data/lib/arel_extensions/nodes/soundex.rb +15 -15
  66. data/lib/arel_extensions/nodes/std.rb +21 -18
  67. data/lib/arel_extensions/nodes/substring.rb +16 -8
  68. data/lib/arel_extensions/nodes/then.rb +1 -1
  69. data/lib/arel_extensions/nodes/trim.rb +6 -4
  70. data/lib/arel_extensions/nodes/union.rb +8 -5
  71. data/lib/arel_extensions/nodes/union_all.rb +7 -4
  72. data/lib/arel_extensions/nodes/wday.rb +4 -0
  73. data/lib/arel_extensions/nodes.rb +1 -1
  74. data/lib/arel_extensions/null_functions.rb +5 -19
  75. data/lib/arel_extensions/predications.rb +44 -45
  76. data/lib/arel_extensions/railtie.rb +5 -5
  77. data/lib/arel_extensions/set_functions.rb +7 -5
  78. data/lib/arel_extensions/string_functions.rb +35 -91
  79. data/lib/arel_extensions/tasks.rb +6 -6
  80. data/lib/arel_extensions/version.rb +1 -1
  81. data/lib/arel_extensions/visitors/ibm_db.rb +31 -24
  82. data/lib/arel_extensions/visitors/mssql.rb +194 -440
  83. data/lib/arel_extensions/visitors/mysql.rb +212 -368
  84. data/lib/arel_extensions/visitors/oracle.rb +179 -236
  85. data/lib/arel_extensions/visitors/oracle12.rb +31 -18
  86. data/lib/arel_extensions/visitors/postgresql.rb +173 -271
  87. data/lib/arel_extensions/visitors/sqlite.rb +127 -157
  88. data/lib/arel_extensions/visitors/to_sql.rb +238 -300
  89. data/lib/arel_extensions/visitors.rb +62 -83
  90. data/lib/arel_extensions.rb +31 -235
  91. data/test/database.yml +10 -20
  92. data/test/helper.rb +18 -0
  93. data/test/real_db_test.rb +118 -121
  94. data/test/support/fake_record.rb +3 -11
  95. data/test/test_comparators.rb +17 -14
  96. data/test/visitors/test_bulk_insert_oracle.rb +12 -12
  97. data/test/visitors/test_bulk_insert_sqlite.rb +14 -13
  98. data/test/visitors/test_bulk_insert_to_sql.rb +13 -11
  99. data/test/visitors/test_oracle.rb +55 -55
  100. data/test/visitors/test_to_sql.rb +226 -419
  101. data/test/with_ar/all_agnostic_test.rb +370 -773
  102. data/test/with_ar/insert_agnostic_test.rb +22 -28
  103. data/test/with_ar/test_bulk_sqlite.rb +17 -18
  104. data/test/with_ar/test_math_sqlite.rb +27 -27
  105. data/test/with_ar/test_string_mysql.rb +34 -32
  106. data/test/with_ar/test_string_sqlite.rb +35 -31
  107. metadata +38 -52
  108. data/.github/workflows/publish.yml +0 -30
  109. data/.github/workflows/release.yml +0 -30
  110. data/.github/workflows/ruby.yml +0 -452
  111. data/CONTRIBUTING.md +0 -102
  112. data/Makefile +0 -18
  113. data/NEWS.md +0 -116
  114. data/bin/build +0 -15
  115. data/bin/publish +0 -8
  116. data/dev/arelx.dockerfile +0 -41
  117. data/dev/compose.yaml +0 -69
  118. data/dev/postgres.dockerfile +0 -5
  119. data/dev/rbenv +0 -189
  120. data/gemfiles/rails5.gemfile +0 -29
  121. data/gemfiles/rails6.gemfile +0 -34
  122. data/gemfiles/rails6_1.gemfile +0 -42
  123. data/gemfiles/rails7.gemfile +0 -42
  124. data/gemfiles/rails7_1.gemfile +0 -41
  125. data/gemfiles/rails7_2.gemfile +0 -41
  126. data/gemfiles/rails8.gemfile +0 -40
  127. data/gemfiles/rails8_1.gemfile +0 -41
  128. data/gemspecs/arel_extensions-v1.gemspec +0 -27
  129. data/gemspecs/arel_extensions-v2.gemspec +0 -27
  130. data/generate_gems.sh +0 -15
  131. data/lib/arel_extensions/aliases.rb +0 -14
  132. data/lib/arel_extensions/constants.rb +0 -13
  133. data/lib/arel_extensions/helpers.rb +0 -61
  134. data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
  135. data/lib/arel_extensions/nodes/byte_size.rb +0 -11
  136. data/lib/arel_extensions/nodes/char_length.rb +0 -11
  137. data/lib/arel_extensions/nodes/formatted_date.rb +0 -42
  138. data/lib/arel_extensions/nodes/rollup.rb +0 -36
  139. data/lib/arel_extensions/nodes/select.rb +0 -10
  140. data/lib/arel_extensions/nodes/sum.rb +0 -7
  141. data/lib/arel_extensions/visitors/convert_format.rb +0 -37
  142. data/lib/arel_extensions/warning.rb +0 -42
  143. data/test/arelx_test_helper.rb +0 -94
  144. data/test/config_loader.rb +0 -9
  145. data/version_v1.rb +0 -3
  146. data/version_v2.rb +0 -3
@@ -1,452 +0,0 @@
1
- name: Build and Test
2
-
3
- # Ruby + Rails Compatibility Matrix from here:
4
- # https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
5
- #
6
- # Images are fixed to ubuntu 22.04 because jruby-9.2 is unavailable in
7
- # ubuntu-24.04 (ubuntu-latest when I tested). Also, for rails < 6, sqlite3
8
- # will not build because libsqlite3-dev is missing.
9
-
10
- on:
11
- push:
12
- branches:
13
- - master
14
- pull_request:
15
- branches:
16
- - master
17
-
18
- jobs:
19
- job_test_to_sql:
20
- name: test to_sql
21
- runs-on: ubuntu-22.04
22
- strategy:
23
- fail-fast: false
24
- matrix:
25
- versions:
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 },
35
- { ruby: "3.3", rails: 7_2, arelx: 2 },
36
- { ruby: "3.3", rails: 7_1, arelx: 2 },
37
- { ruby: "3.3", rails: 7, arelx: 2 },
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 },
41
- { ruby: "3.2", rails: 7_2, arelx: 2 },
42
- { ruby: "3.2", rails: 7_1, arelx: 2 },
43
- { ruby: "3.2", rails: 7, arelx: 2 },
44
- { ruby: "3.2", rails: 6, arelx: 2 },
45
- { ruby: "3.2", rails: 6_1, arelx: 2 },
46
- { ruby: "3.1", rails: 7_2, arelx: 2 },
47
- { ruby: "3.1", rails: 7_1, arelx: 2 },
48
- { ruby: "3.1", rails: 7, arelx: 2 },
49
- { ruby: "3.1", rails: 6_1, arelx: 2 },
50
- { ruby: "3.1", rails: 6, arelx: 2 },
51
- { ruby: "3.0", rails: 7_1, arelx: 2 },
52
- { ruby: "3.0", rails: 7, arelx: 2 },
53
- { ruby: "3.0", rails: 6_1, arelx: 2 },
54
- { ruby: "2.7", rails: 7_1, arelx: 2 },
55
- { ruby: "2.7", rails: 7, arelx: 2 },
56
- { ruby: "2.7", rails: 6_1, arelx: 2 },
57
- { ruby: "2.7", rails: 6, arelx: 2 },
58
- { ruby: "2.7", rails: 5_2, arelx: 1 },
59
- { ruby: jruby-9.2, rails: 6_1, arelx: 2 },
60
- { ruby: jruby-9.2, rails: 6, arelx: 2 },
61
- { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
62
- { ruby: jruby-9.3, rails: 6_1, arelx: 2 },
63
- { ruby: jruby-9.3, rails: 6, arelx: 2 },
64
- { ruby: jruby-9.3, rails: 5_2, arelx: 1 },
65
- ]
66
- steps:
67
- - uses: actions/checkout@v2
68
- - name: Set up Ruby
69
- uses: ruby/setup-ruby@v1
70
- with:
71
- ruby-version: ${{ matrix.versions.ruby }}
72
- - name: Install FreeTDS
73
- run: |
74
- sudo apt-get update -q
75
- sudo apt-get install -y freetds-dev
76
- - name: Setup Gemfile
77
- run: |
78
- cp ./gemspecs/arel_extensions-v${{ matrix.versions.arelx }}.gemspec ./arel_extensions.gemspec
79
- cp ./version_v${{ matrix.versions.arelx }}.rb lib/arel_extensions/version.rb
80
- cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
81
- - name: bundle install
82
- run: |
83
- bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
84
- bundle install
85
- - name: Run test to_sql
86
- run: bundle exec rake test:to_sql
87
-
88
- job_test_sqlite:
89
- name: test sqlite
90
- runs-on: ubuntu-22.04
91
- strategy:
92
- fail-fast: false
93
- matrix:
94
- versions:
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 },
104
- { ruby: "3.3", rails: 7_2, arelx: 2 },
105
- { ruby: "3.3", rails: 7_1, arelx: 2 },
106
- { ruby: "3.3", rails: 7, arelx: 2 },
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 },
110
- { ruby: "3.2", rails: 7_2, arelx: 2 },
111
- { ruby: "3.2", rails: 7_1, arelx: 2 },
112
- { ruby: "3.2", rails: 7, arelx: 2 },
113
- { ruby: "3.2", rails: 6_1, arelx: 2 },
114
- { ruby: "3.2", rails: 6, arelx: 2 },
115
- { ruby: "3.1", rails: 7_2, arelx: 2 },
116
- { ruby: "3.1", rails: 7_1, arelx: 2 },
117
- { ruby: "3.1", rails: 7, arelx: 2 },
118
- { ruby: "3.1", rails: 6, arelx: 2 },
119
- { ruby: "3.1", rails: 6_1, arelx: 2 },
120
- { ruby: "3.0", rails: 7_1, arelx: 2 },
121
- { ruby: "3.0", rails: 7, arelx: 2 },
122
- { ruby: "3.0", rails: 6_1, arelx: 2 },
123
- { ruby: "2.7", rails: 7_1, arelx: 2 },
124
- { ruby: "2.7", rails: 7, arelx: 2 },
125
- { ruby: "2.7", rails: 6_1, arelx: 2 },
126
- { ruby: "2.7", rails: 6, arelx: 2 },
127
- { ruby: "2.7", rails: 5_2, arelx: 1 },
128
- { ruby: jruby-9.2, rails: 6_1, arelx: 2 },
129
- { ruby: jruby-9.2, rails: 6, arelx: 2 },
130
- { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
131
- { ruby: jruby-9.3, rails: 6_1, arelx: 2 },
132
- { ruby: jruby-9.3, rails: 6, arelx: 2 },
133
- { ruby: jruby-9.3, rails: 5_2, arelx: 1 },
134
- ]
135
- steps:
136
- - uses: actions/checkout@v2
137
- - name: Set up Ruby
138
- uses: ruby/setup-ruby@v1
139
- with:
140
- ruby-version: ${{ matrix.versions.ruby }}
141
- - name: Install FreeTDS
142
- run: |
143
- sudo apt-get update -q
144
- sudo apt-get install -y freetds-dev
145
- - name: Setup Gemfile
146
- run: |
147
- cp ./gemspecs/arel_extensions-v${{ matrix.versions.arelx }}.gemspec ./arel_extensions.gemspec
148
- cp ./version_v${{ matrix.versions.arelx }}.rb lib/arel_extensions/version.rb
149
- cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
150
- - name: bundle install
151
- run: |
152
- bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
153
- bundle install
154
- - name: Run test sqlite
155
- run: bundle exec rake test:sqlite
156
-
157
- job_test_postgres:
158
- name: test postgres
159
- runs-on: ubuntu-22.04
160
- strategy:
161
- fail-fast: false
162
- matrix:
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 },
172
- { ruby: "3.3", rails: 7_2, arelx: 2 },
173
- { ruby: "3.3", rails: 7_1, arelx: 2 },
174
- { ruby: "3.3", rails: 7, arelx: 2 },
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 },
178
- { ruby: "3.2", rails: 7_2, arelx: 2 },
179
- { ruby: "3.2", rails: 7_1, arelx: 2 },
180
- { ruby: "3.2", rails: 7, arelx: 2 },
181
- { ruby: "3.2", rails: 6_1, arelx: 2 },
182
- # { ruby: "3.2", rails: 6, arelx: 2 }, # cannot test > undefined symbol: rb_tainted_str_new2
183
- { ruby: "3.1", rails: 7_2, arelx: 2 },
184
- { ruby: "3.1", rails: 7_1, arelx: 2 },
185
- { ruby: "3.1", rails: 7, arelx: 2 },
186
- { ruby: "3.1", rails: 6_1, arelx: 2 },
187
- { ruby: "3.1", rails: 6, arelx: 2 },
188
- { ruby: "3.0", rails: 7_1, arelx: 2 },
189
- { ruby: "3.0", rails: 7, arelx: 2 },
190
- { ruby: "3.0", rails: 6_1, arelx: 2 },
191
- { ruby: "2.7", rails: 7_1, arelx: 2 },
192
- { ruby: "2.7", rails: 7, arelx: 2 },
193
- { ruby: "2.7", rails: 6_1, arelx: 2 },
194
- { ruby: "2.7", rails: 6, arelx: 2 },
195
- { ruby: "2.7", rails: 5_2, arelx: 1 },
196
- { ruby: jruby-9.2, rails: 6_1, arelx: 2 },
197
- { ruby: jruby-9.2, rails: 6, arelx: 2 },
198
- { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
199
- { ruby: jruby-9.3, rails: 6_1, arelx: 2 },
200
- { ruby: jruby-9.3, rails: 6, arelx: 2 },
201
- { ruby: jruby-9.3, rails: 5_2, arelx: 1 },
202
- ]
203
- steps:
204
- - uses: actions/checkout@v2
205
- # PostgreSQL requires locales to be installed on the system to be able
206
- # to do time and currency conversions at runtime.
207
- #
208
- # That's why we're not launching it as a service; pre-built images
209
- # lack loaclization.
210
- #
211
- # After we install locales, we'll install PostgreSQL binaries and start
212
- # the service.
213
- - name: setup locale
214
- run: |
215
- sudo locale-gen fr_FR.utf8
216
- sudo update-locale
217
- - name: setup postgres 11
218
- run: |
219
- curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
220
- echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
221
- sudo apt update
222
- sudo apt -y install postgresql-11
223
- sudo systemctl enable postgresql
224
- sudo systemctl start postgresql
225
- sudo su -c "psql -c \"alter user postgres with password 'secret'\"" postgres
226
- sudo su -c "createdb arelx_test" postgres
227
- - name: Set up Ruby
228
- uses: ruby/setup-ruby@v1
229
- with:
230
- ruby-version: ${{ matrix.versions.ruby }}
231
- - name: Install FreeTDS
232
- run: |
233
- sudo apt-get update -q
234
- sudo apt-get install -y freetds-dev
235
- - name: Setup Gemfile
236
- run: |
237
- cp ./gemspecs/arel_extensions-v${{ matrix.versions.arelx }}.gemspec ./arel_extensions.gemspec
238
- cp ./version_v${{ matrix.versions.arelx }}.rb lib/arel_extensions/version.rb
239
- cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
240
- - name: bundle install
241
- run: |
242
- bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
243
- bundle install
244
- - name: Run test Postgres
245
- env:
246
- PGHOST: localhost
247
- PGUSER: postgres
248
- run: bundle exec rake test:postgresql
249
-
250
- job_test_mysql:
251
- name: test mysql
252
- runs-on: ubuntu-22.04
253
- strategy:
254
- fail-fast: false
255
- matrix:
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 },
265
- { ruby: "3.3", rails: 7_2, arelx: 2 },
266
- { ruby: "3.3", rails: 7_1, arelx: 2 },
267
- { ruby: "3.3", rails: 7, arelx: 2 },
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 },
271
- { ruby: "3.2", rails: 7_2, arelx: 2 },
272
- { ruby: "3.2", rails: 7_1, arelx: 2 },
273
- { ruby: "3.2", rails: 7, arelx: 2 },
274
- { ruby: "3.2", rails: 6_1, arelx: 2 },
275
- # { ruby: "3.2", rails: 6, arelx: 2 }, # cannot test > undefined symbol: rb_tainted_str_new2
276
- { ruby: "3.1", rails: 7_2, arelx: 2 },
277
- { ruby: "3.1", rails: 7_1, arelx: 2 },
278
- { ruby: "3.1", rails: 7, arelx: 2 },
279
- { ruby: "3.1", rails: 6_1, arelx: 2 },
280
- { ruby: "3.1", rails: 6, arelx: 2 },
281
- { ruby: "3.0", rails: 7_1, arelx: 2 },
282
- { ruby: "3.0", rails: 7, arelx: 2 },
283
- { ruby: "3.0", rails: 6_1, arelx: 2 },
284
- { ruby: "2.7", rails: 7_1, arelx: 2 },
285
- { ruby: "2.7", rails: 7, arelx: 2 },
286
- { ruby: "2.7", rails: 6_1, arelx: 2 },
287
- { ruby: "2.7", rails: 6, arelx: 2 },
288
- { ruby: "2.7", rails: 5_2, arelx: 1 },
289
- { ruby: jruby-9.2, rails: 6_1, arelx: 2 },
290
- { ruby: jruby-9.2, rails: 6, arelx: 2 },
291
- { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
292
- { ruby: jruby-9.3, rails: 6_1, arelx: 2 },
293
- { ruby: jruby-9.3, rails: 6, arelx: 2 },
294
- { ruby: jruby-9.3, rails: 5_2, arelx: 1 },
295
- ]
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
- #
315
- steps:
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
-
339
- - name: Set up Ruby
340
- uses: ruby/setup-ruby@v1
341
- with:
342
- ruby-version: ${{ matrix.versions.ruby }}
343
- - name: Install FreeTDS
344
- run: |
345
- sudo apt-get update -q
346
- sudo apt-get install -y freetds-dev
347
- - name: Setup Gemfile
348
- run: |
349
- cp ./gemspecs/arel_extensions-v${{ matrix.versions.arelx }}.gemspec ./arel_extensions.gemspec
350
- cp ./version_v${{ matrix.versions.arelx }}.rb lib/arel_extensions/version.rb
351
- cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
352
- - name: bundle install
353
- run: |
354
- bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
355
- bundle install
356
- - name: Run test MySql
357
- env:
358
- DB_CONNECTION: mysql
359
- DB_HOST: 127.0.0.1
360
- DB_PORT: 3306
361
- DB_DATABASE: arelx_test
362
- DB_USERNAME: root
363
- run: bundle exec rake test:mysql
364
-
365
- job_test_mssql:
366
- name: test mssql on linux
367
- runs-on: ubuntu-22.04
368
- strategy:
369
- fail-fast: false
370
- matrix:
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 },
381
- { ruby: "3.3", rails: 7_1, arelx: 2 },
382
- { ruby: "3.3", rails: 7, arelx: 2 },
383
- { ruby: "3.3", rails: 6_1, arelx: 2 },
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 },
387
- { ruby: "3.2", rails: 7_1, arelx: 2 },
388
- { ruby: "3.2", rails: 7, arelx: 2 },
389
- { ruby: "3.2", rails: 6_1, arelx: 2 },
390
- { ruby: "3.2", rails: 6, arelx: 2 },
391
- { ruby: "3.1", rails: 7_1, arelx: 2 },
392
- { ruby: "3.1", rails: 7, arelx: 2 },
393
- { ruby: "3.1", rails: 6_1, arelx: 2 },
394
- { ruby: "3.1", rails: 6, arelx: 2 },
395
- { ruby: "3.0", rails: 7, arelx: 2 },
396
- { ruby: "3.0", rails: 6_1, arelx: 2 },
397
- { ruby: "3.0", rails: 6, arelx: 2 },
398
- { ruby: "2.7", rails: 6_1, arelx: 2 },
399
- { ruby: "2.7", rails: 6, arelx: 2 },
400
- { ruby: "2.7", rails: 5_2, arelx: 1 },
401
- # {ruby: jruby-9.2, rails: 6_1, arelx: 2},
402
- # {ruby: jruby-9.2, rails: 6, arelx: 2},
403
- { ruby: jruby-9.2, rails: 5_2, arelx: 1 },
404
- # See comments on 9.4 to understand why these are disabled for now.
405
- # {ruby: jruby-9.3, rails: 6_1, arelx: 2},
406
- # {ruby: jruby-9.3, rails: 6, arelx: 2},
407
- # {ruby: jruby-9.3, rails: 5_2, arelx: 1},
408
- { ruby: jruby-9.4.10, rails: 7_1, arelx: 2 }, # The reason we pin to the patch level is https://github.com/ruby/psych/issues/700
409
- { ruby: jruby-9.4.10, rails: 7, arelx: 2 },
410
- #
411
- # 6 and 6.1 don't work because of a bug in the alt adapter
412
- # https://github.com/JesseChavez/activerecord-jdbc-adapter/issues/16
413
- # {ruby: jruby-9.4, rails: 6_1, arelx: 2},
414
- # {ruby: jruby-9.4, rails: 6, arelx: 2},
415
- #
416
- # < 5.2 don't work because of a deeper issue.
417
- # {ruby: jruby-9.4, rails: 5_2, arelx: 1},
418
- ]
419
- mssql: [2017, 2019]
420
- steps:
421
- - uses: actions/checkout@v2
422
- - name: Set up Ruby
423
- uses: ruby/setup-ruby@v1
424
- with:
425
- ruby-version: ${{ matrix.versions.ruby }}
426
- - name: Install FreeTDS
427
- run: |
428
- sudo apt-get update -q
429
- sudo apt-get install -y freetds-dev
430
- - name: Install MSSQL ${{ matrix.mssql }}
431
- uses: potatoqualitee/mssqlsuite@v1.5.1
432
- with:
433
- version: ${{ matrix.mssql }}
434
- install: sqlengine, sqlclient, sqlpackage, localdb
435
- sa-password: Password12!
436
- - name: Setup Gemfile
437
- run: |
438
- cp ./gemspecs/arel_extensions-v${{ matrix.versions.arelx }}.gemspec ./arel_extensions.gemspec
439
- cp ./version_v${{ matrix.versions.arelx }}.rb lib/arel_extensions/version.rb
440
- cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
441
- - name: bundle install
442
- run: |
443
- bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
444
- bundle install
445
- - name: Run test mssql [mri]
446
- if: ${{ !contains(matrix.versions.ruby, 'jruby') }}
447
- run: bundle exec rake test:mssql
448
- - name: Run test mssql [jruby]
449
- if: ${{ contains(matrix.versions.ruby, 'jruby') }}
450
- run: |
451
- curl -LO https://github.com/microsoft/mssql-jdbc/releases/download/v8.4.1/mssql-jdbc-8.4.1.jre11.jar
452
- CLASSPATH=".:mssql-jdbc-8.4.1.jre11.jar" bundle exec rake test:mssql
data/CONTRIBUTING.md DELETED
@@ -1,102 +0,0 @@
1
- # Contributing
2
-
3
- Your PRs are welcome.
4
-
5
- ## Local Development
6
-
7
- Let's say you want to develop/test for `ruby 2.7.5` and `rails 5.2`.
8
-
9
- You will need to fix your ruby version:
10
-
11
- ```bash
12
- rbenv install 2.7.5
13
- rbenv local 2.7.5
14
- ```
15
-
16
- Fix your gemfiles:
17
-
18
- ```bash
19
- bundle config set --local gemfile ./gemfiles/rails6.gemfile
20
- cp gemspecs/arel_extensions-v2.gemspec arel_extensions.gemspec
21
- ```
22
-
23
- Or by copying:
24
-
25
- ```bash
26
- cp gemfiles/gemfiles/rails6.gemfile Gemfiles
27
- cp gemspecs/arel_extensions-v2.gemspec arel_extensions.gemspec
28
- ```
29
-
30
- Install dependencies:
31
- ```bash
32
- bundle install
33
- ```
34
-
35
- > [!IMPORTANT]
36
- > Sometimes you might need to delete `vendor` dirs.
37
- > If you use `bundle config set --local gemfile`, it will be in `gemfiles/vendor`.
38
- > If you just `cp gemfiles/…`, it will be in `vendor`.
39
-
40
- Develop, then test:
41
-
42
- ```bash
43
- bundle exec rake test:to_sql
44
- ```
45
-
46
- Refer to the [Version Compatibility](#version-compatibility) section to correctly
47
- set your gemfile.
48
-
49
- ## Testing many DBs without installing them
50
-
51
- We provide a `docker compose` to set up some databases for testing:
52
-
53
- ```bash
54
- docker compose -f dev/compose.yaml up --exit-code-from arelx
55
- ```
56
-
57
- Or simply call `bin/compose`.
58
-
59
- The databases, versions of arelx, and versions of ruby are all read from the
60
- matrixes defined in `.github/workflow/ruby.yml`. To test a specific
61
- configuration, all you have to do is comment the versions you're not
62
- insterested in.
63
-
64
- > [!IMPORTANT]
65
- > This methods conflicts with the [Local development](#local-development) method.
66
- > If you find yourself jumping between both, make sure you delete `Gemfile.lock`
67
- > and `vendor/`.
68
-
69
- ### VSCode
70
-
71
- You can use the following `launch.json` to debug:
72
-
73
- ```json
74
- {
75
- "version": "0.2.0",
76
- "configurations": [
77
- {
78
- "type": "rdbg",
79
- "name": "Debug DB",
80
- "request": "launch",
81
- "cwd": "${workspaceRoot}",
82
- "script": "test/with_ar/all_agnostic_test.rb",
83
- "command": "bundle exec ruby -Ilib -Itest",
84
- "env": {
85
- "DB": "postgresql"
86
- },
87
- "useBundler": false,
88
- "askParameters": false
89
- },
90
- {
91
- "type": "rdbg",
92
- "name": "Debug to_sql",
93
- "request": "launch",
94
- "cwd": "${workspaceRoot}",
95
- "script": "test/visitors/test_to_sql.rb",
96
- "command": "bundle exec ruby -Ilib -Itest",
97
- "useBundler": false,
98
- "askParameters": false
99
- }
100
- ]
101
- }
102
- ```
data/Makefile DELETED
@@ -1,18 +0,0 @@
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 DELETED
@@ -1,116 +0,0 @@
1
- # News
2
-
3
- ## [unreleased]
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
-
12
- ## Release v2.3.3/v1.5.3 (11-02-2025)
13
-
14
- - Fix the `&` operator which does `find_in_set` for mysql and postgres, accepting strings and integers.
15
- - Add `regex_matches`, an alias for `=~`.
16
-
17
- ## Release v2.3.2/v1.5.2 (02-01-2025)
18
-
19
- - Fix a subtle bug on table access as in `table[:col]` in certain situations.
20
- - `==` and `!=` deprecation warnings can stem from `arel` itself, so now we don't emit them because they're plain wrong.
21
-
22
- ## Release v2.3.1/v1.5.1 (20-12-2024)
23
-
24
- - Fallback to Ruby's Warning module if ActiveSupport doesn't exist. Relevant for old Rails versions.
25
- - Added documentation on how to _"properly"_ configure the deprecator in a Rails application.
26
-
27
- ## Release v2.3.0/v1.5.0 (19-12-2024)
28
-
29
- - Use ActiveSupport's deprecation machinery instead of Ruby's Warning module.
30
- - Fix a bug with group concat that didn't correctly check for the separator value.
31
-
32
- ## Release v2.2.2/v1.4.2 (27-11-2024)
33
-
34
- - Fix deprecation warnings for `==` and `!=`, showing the true location.
35
- - Always emit deprecation warnings for `==` and `!=`.
36
-
37
- ## Release v2.2.1/v1.4.1 (08-11-2024)
38
-
39
- - Improved deprecation warnings for `==` and `!=`, showing the location where they're called.
40
-
41
- ## Release v2.2.0/v1.4.0
42
-
43
- - MS SQL: restrict date-quoting to Arel <= 6 (Rails 4.2)
44
- - MS SQL: turn on warnings on requires only when gem is found
45
- - Rails: 7.2 support for mysql, postgres, and sqlite.
46
- - Attributes: deprecate `==` and `!=`. They're causing issues with
47
- `active_record`, and they're not sanitary.
48
-
49
- ## Release v2.1.11/v1.3.11
50
-
51
- - MS SQL: turn on warnings on requires only when necessary.
52
-
53
- ## Release v2.1.10/v1.3.10
54
-
55
- - MS SQL: add support for jruby 9.4 via [activerecord-jdbc-alt-adapter](https://rubygems.org/gems/activerecord-jdbc-alt-adapter/)
56
-
57
- ## Release v2.1.9/v1.3.9
58
-
59
- ### Bug Fixes
60
-
61
- - Postgres:
62
- - Datetime formatting in postgres now behaves like mysql: if the target
63
- timezone is a string, we automatically consider that you're trying to
64
- convert from `UTC`.
65
- - Datetime casting will now automatically ask for a
66
- `timestamp without timezone`, also aligning with the expected befavior
67
- in mysql. This also makes casting work better with timezone conversion,
68
- especially if you don't pass the timezone from which you're converting
69
- to.
70
- ```ruby
71
- scope
72
- .select(Arel.quoted('2022-02-01 10:42:00')
73
- .cast(:datetime)
74
- .format_date('%Y/%m/%d %H:%M:%S', 'Europe/Paris')
75
- .as('res'))
76
- ```
77
- Will produce:
78
- ```sql
79
- SELECT TO_CHAR(
80
- CAST('2022-02-01 10:42:00' AS timestamp without time zone) AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Paris',
81
- 'YYYY/MM/DD HH24:MI:SS'
82
- )
83
- AS "res"
84
- -- …
85
- ```
86
-
87
- ## Release v2.1.7/v1.3.7
88
-
89
- ### New Features
90
-
91
- - `o.format_date` as an alternative to `o.format`
92
- The actual behavior of `format` is inconsistent across DB vendors: in mysql we
93
- can format dates and numbers with it, and in the other ones we only format
94
- dates.
95
-
96
- We're planning on normalizing this behavior. We want `format` to "cleverly"
97
- format dates or numbers, and `format_date` / `format_number` to strictly
98
- format dates / numbers.
99
-
100
- The introduction of `format_date` is the first step in this direction.
101
-
102
- ## Release v2.1.6/v1.3.6
103
-
104
- ### Bug Fixes
105
-
106
- - This used to fail.
107
- ```
108
- Arel.when(a).then(b).format('%Y-%m-%d')
109
- ```
110
-
111
- ### New Features
112
-
113
- - `o.present`, a synonym for `o.not_blank`
114
- - `o.coalesce_blank(a, b, c)`
115
- - `o.if_present`, if the value is `null` or blank, then it returns `null`,
116
- otherwise, it returns the value. Inspired by rails' `presence`.