arel_extensions 1.3.4 → 2.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +2 -1
- data/.rubocop.yml +4 -31
- data/.travis/oracle/download.js +152 -0
- data/.travis/oracle/download.sh +30 -0
- data/.travis/oracle/download_ojdbc.js +116 -0
- data/.travis/oracle/install.sh +34 -0
- data/.travis/setup_accounts.sh +9 -0
- data/.travis/sqlite3/extension-functions.sh +6 -0
- data/.travis.yml +223 -0
- data/Gemfile +21 -16
- data/README.md +14 -125
- data/Rakefile +30 -41
- data/TODO +1 -0
- data/appveyor.yml +44 -0
- data/arel_extensions.gemspec +14 -14
- data/functions.html +3 -3
- data/gemfiles/rails3.gemfile +10 -10
- data/gemfiles/rails4.gemfile +14 -14
- data/gemfiles/rails5_0.gemfile +14 -14
- data/gemfiles/rails5_1_4.gemfile +14 -14
- data/gemfiles/rails5_2.gemfile +14 -15
- data/init/mssql.sql +4 -4
- data/init/mysql.sql +38 -38
- data/init/oracle.sql +0 -0
- data/init/postgresql.sql +21 -21
- data/init/sqlite.sql +0 -0
- data/lib/arel_extensions/attributes.rb +3 -4
- data/lib/arel_extensions/boolean_functions.rb +14 -53
- data/lib/arel_extensions/common_sql_functions.rb +16 -15
- data/lib/arel_extensions/comparators.rb +28 -27
- data/lib/arel_extensions/date_duration.rb +14 -13
- data/lib/arel_extensions/insert_manager.rb +15 -18
- data/lib/arel_extensions/math.rb +44 -31
- data/lib/arel_extensions/math_functions.rb +39 -46
- data/lib/arel_extensions/nodes/abs.rb +1 -0
- data/lib/arel_extensions/nodes/blank.rb +2 -1
- data/lib/arel_extensions/nodes/case.rb +16 -16
- data/lib/arel_extensions/nodes/cast.rb +6 -8
- data/lib/arel_extensions/nodes/ceil.rb +1 -1
- data/lib/arel_extensions/nodes/coalesce.rb +3 -2
- data/lib/arel_extensions/nodes/collate.rb +10 -9
- data/lib/arel_extensions/nodes/concat.rb +18 -9
- data/lib/arel_extensions/nodes/date_diff.rb +22 -38
- data/lib/arel_extensions/nodes/duration.rb +3 -0
- data/lib/arel_extensions/nodes/find_in_set.rb +1 -0
- data/lib/arel_extensions/nodes/floor.rb +1 -1
- data/lib/arel_extensions/nodes/format.rb +8 -35
- data/lib/arel_extensions/nodes/formatted_number.rb +23 -22
- data/lib/arel_extensions/nodes/function.rb +37 -42
- data/lib/arel_extensions/nodes/is_null.rb +0 -0
- data/lib/arel_extensions/nodes/json.rb +39 -48
- data/lib/arel_extensions/nodes/length.rb +0 -5
- data/lib/arel_extensions/nodes/levenshtein_distance.rb +1 -1
- data/lib/arel_extensions/nodes/locate.rb +1 -0
- data/lib/arel_extensions/nodes/log10.rb +2 -1
- data/lib/arel_extensions/nodes/matches.rb +7 -5
- data/lib/arel_extensions/nodes/md5.rb +1 -0
- data/lib/arel_extensions/nodes/power.rb +5 -5
- data/lib/arel_extensions/nodes/rand.rb +1 -0
- data/lib/arel_extensions/nodes/repeat.rb +4 -2
- data/lib/arel_extensions/nodes/replace.rb +8 -16
- data/lib/arel_extensions/nodes/round.rb +6 -5
- data/lib/arel_extensions/nodes/soundex.rb +15 -15
- data/lib/arel_extensions/nodes/std.rb +21 -18
- data/lib/arel_extensions/nodes/substring.rb +16 -8
- data/lib/arel_extensions/nodes/trim.rb +5 -3
- data/lib/arel_extensions/nodes/union.rb +8 -5
- data/lib/arel_extensions/nodes/union_all.rb +7 -4
- data/lib/arel_extensions/nodes/wday.rb +4 -0
- data/lib/arel_extensions/nodes.rb +1 -1
- data/lib/arel_extensions/null_functions.rb +7 -5
- data/lib/arel_extensions/predications.rb +43 -44
- data/lib/arel_extensions/railtie.rb +5 -5
- data/lib/arel_extensions/set_functions.rb +7 -5
- data/lib/arel_extensions/string_functions.rb +29 -58
- data/lib/arel_extensions/tasks.rb +6 -6
- data/lib/arel_extensions/version.rb +1 -1
- data/lib/arel_extensions/visitors/ibm_db.rb +31 -24
- data/lib/arel_extensions/visitors/mssql.rb +184 -269
- data/lib/arel_extensions/visitors/mysql.rb +206 -271
- data/lib/arel_extensions/visitors/oracle.rb +175 -191
- data/lib/arel_extensions/visitors/oracle12.rb +31 -18
- data/lib/arel_extensions/visitors/postgresql.rb +170 -244
- data/lib/arel_extensions/visitors/sqlite.rb +124 -138
- data/lib/arel_extensions/visitors/to_sql.rb +237 -269
- data/lib/arel_extensions/visitors.rb +59 -75
- data/lib/arel_extensions.rb +31 -149
- data/test/database.yml +7 -15
- data/test/helper.rb +18 -0
- data/test/real_db_test.rb +113 -102
- data/test/support/fake_record.rb +3 -3
- data/test/test_comparators.rb +17 -14
- data/test/visitors/test_bulk_insert_oracle.rb +10 -10
- data/test/visitors/test_bulk_insert_sqlite.rb +12 -11
- data/test/visitors/test_bulk_insert_to_sql.rb +12 -10
- data/test/visitors/test_oracle.rb +55 -55
- data/test/visitors/test_to_sql.rb +226 -419
- data/test/with_ar/all_agnostic_test.rb +357 -567
- data/test/with_ar/insert_agnostic_test.rb +19 -25
- data/test/with_ar/test_bulk_sqlite.rb +15 -16
- data/test/with_ar/test_math_sqlite.rb +26 -26
- data/test/with_ar/test_string_mysql.rb +33 -31
- data/test/with_ar/test_string_sqlite.rb +34 -30
- metadata +23 -29
- data/.github/workflows/ruby.yml +0 -389
- data/gemfiles/rails6.gemfile +0 -29
- data/gemfiles/rails6_1.gemfile +0 -29
- data/gemfiles/rails7.gemfile +0 -22
- data/gemspecs/arel_extensions-v1.gemspec +0 -28
- data/gemspecs/arel_extensions-v2.gemspec +0 -28
- data/generate_gems.sh +0 -15
- data/lib/arel_extensions/aliases.rb +0 -14
- data/lib/arel_extensions/helpers.rb +0 -51
- data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
- data/lib/arel_extensions/nodes/sum.rb +0 -7
- data/lib/arel_extensions/visitors/convert_format.rb +0 -37
- data/test/arelx_test_helper.rb +0 -71
- data/version_v1.rb +0 -3
- data/version_v2.rb +0 -3
data/.github/workflows/ruby.yml
DELETED
@@ -1,389 +0,0 @@
|
|
1
|
-
name: Build and Test
|
2
|
-
|
3
|
-
# Ruby + Rails Compatibility Matrix from here:
|
4
|
-
# https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
|
5
|
-
|
6
|
-
on: [push, pull_request]
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
job_build_gem:
|
10
|
-
name: build
|
11
|
-
runs-on: ubuntu-latest
|
12
|
-
strategy:
|
13
|
-
matrix:
|
14
|
-
ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
|
15
|
-
rails: [7, 6_1, 6, 5_2]
|
16
|
-
exclude: [
|
17
|
-
{ruby: 3.1, rails: 6 },
|
18
|
-
{ruby: 3.1, rails: 5_2},
|
19
|
-
{ruby: 3.0, rails: 6 },
|
20
|
-
{ruby: 3.0, rails: 5_2},
|
21
|
-
{ruby: 2.7, rails: 5_2},
|
22
|
-
{ruby: 2.5, rails: 7 },
|
23
|
-
{ruby: jruby-9.2, rails: 7 },
|
24
|
-
{ruby: jruby-9.3, rails: 7 },
|
25
|
-
]
|
26
|
-
steps:
|
27
|
-
- uses: actions/checkout@v2
|
28
|
-
- name: Set up Ruby
|
29
|
-
uses: ruby/setup-ruby@v1
|
30
|
-
with:
|
31
|
-
ruby-version: ${{ matrix.ruby }}
|
32
|
-
- name: Setup gemspec
|
33
|
-
if: ${{ matrix.rails != '5_2' }}
|
34
|
-
run: |
|
35
|
-
cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
36
|
-
cp ./version_v2.rb lib/arel_extensions/version.rb
|
37
|
-
cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
|
38
|
-
- name: Build source gem
|
39
|
-
run: gem build arel_extensions.gemspec
|
40
|
-
- name: Upload source gem
|
41
|
-
uses: actions/upload-artifact@v2
|
42
|
-
with:
|
43
|
-
name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
|
44
|
-
path: "*.gem"
|
45
|
-
|
46
|
-
job_test_to_sql:
|
47
|
-
name: test to_sql
|
48
|
-
needs: job_build_gem
|
49
|
-
runs-on: ubuntu-latest
|
50
|
-
strategy:
|
51
|
-
fail-fast: false
|
52
|
-
matrix:
|
53
|
-
ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
|
54
|
-
rails: [7, 6_1, 6, 5_2]
|
55
|
-
exclude: [
|
56
|
-
{ruby: 3.1, rails: 6 },
|
57
|
-
{ruby: 3.1, rails: 5_2},
|
58
|
-
{ruby: 3.0, rails: 6 },
|
59
|
-
{ruby: 3.0, rails: 5_2},
|
60
|
-
{ruby: 2.7, rails: 5_2},
|
61
|
-
{ruby: 2.5, rails: 7 },
|
62
|
-
{ruby: jruby-9.2, rails: 7},
|
63
|
-
{ruby: jruby-9.3, rails: 7},
|
64
|
-
]
|
65
|
-
steps:
|
66
|
-
- uses: actions/checkout@v2
|
67
|
-
- name: Set up Ruby
|
68
|
-
uses: ruby/setup-ruby@v1
|
69
|
-
with:
|
70
|
-
ruby-version: ${{ matrix.ruby }}
|
71
|
-
- name: Install FreeTDS
|
72
|
-
run: |
|
73
|
-
sudo apt-get update -q
|
74
|
-
sudo apt-get install -y freetds-dev
|
75
|
-
- name: Update system-wide gems
|
76
|
-
run: gem update --system
|
77
|
-
- name: Download gem from build job
|
78
|
-
uses: actions/download-artifact@v2
|
79
|
-
with:
|
80
|
-
name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
|
81
|
-
- name: Setup Gemfile
|
82
|
-
if: ${{ matrix.rails != '5_2' }}
|
83
|
-
run: |
|
84
|
-
cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
85
|
-
cp ./version_v2.rb lib/arel_extensions/version.rb
|
86
|
-
cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
|
87
|
-
- name: bundle install
|
88
|
-
run: |
|
89
|
-
bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
|
90
|
-
bundle install
|
91
|
-
- name: Run test to_sql
|
92
|
-
run: bundle exec rake test:to_sql
|
93
|
-
|
94
|
-
job_test_sqlite:
|
95
|
-
name: test sqlite
|
96
|
-
needs: job_build_gem
|
97
|
-
runs-on: ubuntu-latest
|
98
|
-
strategy:
|
99
|
-
fail-fast: false
|
100
|
-
matrix:
|
101
|
-
ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
|
102
|
-
rails: [7, 6_1, 6, 5_2]
|
103
|
-
exclude: [
|
104
|
-
{ruby: 3.1, rails: 6 },
|
105
|
-
{ruby: 3.1, rails: 5_2},
|
106
|
-
{ruby: 3.0, rails: 6 },
|
107
|
-
{ruby: 3.0, rails: 5_2},
|
108
|
-
{ruby: 2.7, rails: 5_2},
|
109
|
-
{ruby: 2.5, rails: 7 },
|
110
|
-
{ruby: jruby-9.2, rails: 7},
|
111
|
-
{ruby: jruby-9.3, rails: 7},
|
112
|
-
]
|
113
|
-
steps:
|
114
|
-
- uses: actions/checkout@v2
|
115
|
-
- name: Set up Ruby
|
116
|
-
uses: ruby/setup-ruby@v1
|
117
|
-
with:
|
118
|
-
ruby-version: ${{ matrix.ruby }}
|
119
|
-
- name: Install FreeTDS
|
120
|
-
run: |
|
121
|
-
sudo apt-get update -q
|
122
|
-
sudo apt-get install -y freetds-dev
|
123
|
-
- name: Update system-wide gems
|
124
|
-
run: gem update --system
|
125
|
-
- name: Download gem from build job
|
126
|
-
uses: actions/download-artifact@v2
|
127
|
-
with:
|
128
|
-
name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
|
129
|
-
- name: Setup Gemfile
|
130
|
-
if: ${{ matrix.rails != '5_2' }}
|
131
|
-
run: |
|
132
|
-
cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
133
|
-
cp ./version_v2.rb lib/arel_extensions/version.rb
|
134
|
-
cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
|
135
|
-
- name: bundle install
|
136
|
-
run: |
|
137
|
-
bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
|
138
|
-
bundle install
|
139
|
-
- name: Run test sqlite
|
140
|
-
run: bundle exec rake test:sqlite
|
141
|
-
|
142
|
-
job_test_postgres:
|
143
|
-
name: test postgres
|
144
|
-
needs: job_build_gem
|
145
|
-
runs-on: ubuntu-latest
|
146
|
-
strategy:
|
147
|
-
fail-fast: false
|
148
|
-
matrix:
|
149
|
-
ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
|
150
|
-
rails: [7, 6_1, 6, 5_2]
|
151
|
-
exclude: [
|
152
|
-
{ruby: 3.1, rails: 6 },
|
153
|
-
{ruby: 3.1, rails: 5_2},
|
154
|
-
{ruby: 3.0, rails: 6 },
|
155
|
-
{ruby: 3.0, rails: 5_2},
|
156
|
-
{ruby: 2.7, rails: 5_2},
|
157
|
-
{ruby: 2.5, rails: 7 },
|
158
|
-
{ruby: jruby-9.2, rails: 7},
|
159
|
-
{ruby: jruby-9.3, rails: 7},
|
160
|
-
]
|
161
|
-
services:
|
162
|
-
postgres:
|
163
|
-
image: postgres:11.6-alpine
|
164
|
-
env:
|
165
|
-
POSTGRES_DB: arelx_test
|
166
|
-
POSTGRES_PASSWORD: secret
|
167
|
-
ports:
|
168
|
-
- 5432:5432
|
169
|
-
# needed because the postgres container does not provide a healthcheck
|
170
|
-
options: >-
|
171
|
-
--health-cmd "pg_isready -d arelx_test -U postgres -p 5432"
|
172
|
-
--health-interval 10s
|
173
|
-
--health-timeout 5s
|
174
|
-
--health-retries 5
|
175
|
-
steps:
|
176
|
-
- uses: actions/checkout@v2
|
177
|
-
- name: Set up Ruby
|
178
|
-
uses: ruby/setup-ruby@v1
|
179
|
-
with:
|
180
|
-
ruby-version: ${{ matrix.ruby }}
|
181
|
-
- name: Install FreeTDS
|
182
|
-
run: |
|
183
|
-
sudo apt-get update -q
|
184
|
-
sudo apt-get install -y freetds-dev
|
185
|
-
- name: Update system-wide gems
|
186
|
-
run: gem update --system
|
187
|
-
- name: Download gem from build job
|
188
|
-
uses: actions/download-artifact@v2
|
189
|
-
with:
|
190
|
-
name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
|
191
|
-
- name: Setup Gemfile
|
192
|
-
if: ${{ matrix.rails != '5_2' }}
|
193
|
-
run: |
|
194
|
-
cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
195
|
-
cp ./version_v2.rb lib/arel_extensions/version.rb
|
196
|
-
cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
|
197
|
-
- name: bundle install
|
198
|
-
run: |
|
199
|
-
bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
|
200
|
-
bundle install
|
201
|
-
- name: Run test Postgres
|
202
|
-
env:
|
203
|
-
PGHOST: localhost
|
204
|
-
PGUSER: postgres
|
205
|
-
run: bundle exec rake test:postgresql
|
206
|
-
|
207
|
-
job_test_mysql:
|
208
|
-
name: test mysql
|
209
|
-
needs: job_build_gem
|
210
|
-
runs-on: ubuntu-latest
|
211
|
-
strategy:
|
212
|
-
fail-fast: false
|
213
|
-
matrix:
|
214
|
-
ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
|
215
|
-
rails: [7, 6_1, 6, 5_2]
|
216
|
-
exclude: [
|
217
|
-
{ruby: 3.1, rails: 6 },
|
218
|
-
{ruby: 3.1, rails: 5_2},
|
219
|
-
{ruby: 3.0, rails: 6 },
|
220
|
-
{ruby: 3.0, rails: 5_2},
|
221
|
-
{ruby: 2.7, rails: 5_2},
|
222
|
-
{ruby: 2.5, rails: 7 },
|
223
|
-
{ruby: jruby-9.2, rails: 7 },
|
224
|
-
{ruby: jruby-9.3, rails: 7 },
|
225
|
-
]
|
226
|
-
services:
|
227
|
-
mysql:
|
228
|
-
image: mysql:5.7
|
229
|
-
env:
|
230
|
-
MYSQL_ALLOW_EMPTY_PASSWORD: true
|
231
|
-
MYSQL_USERNAME: root
|
232
|
-
MYSQL_DATABASE: arelx_test
|
233
|
-
ports:
|
234
|
-
- 3306:3306
|
235
|
-
options: >-
|
236
|
-
--health-cmd="mysqladmin ping"
|
237
|
-
--health-interval=10s
|
238
|
-
--health-timeout=5s
|
239
|
-
--health-retries=3
|
240
|
-
steps:
|
241
|
-
- uses: actions/checkout@v2
|
242
|
-
- name: Set up Ruby
|
243
|
-
uses: ruby/setup-ruby@v1
|
244
|
-
with:
|
245
|
-
ruby-version: ${{ matrix.ruby }}
|
246
|
-
- name: Install FreeTDS
|
247
|
-
run: |
|
248
|
-
sudo apt-get update -q
|
249
|
-
sudo apt-get install -y freetds-dev
|
250
|
-
- name: Update system-wide gems
|
251
|
-
run: gem update --system
|
252
|
-
- name: Download gem from build job
|
253
|
-
uses: actions/download-artifact@v2
|
254
|
-
with:
|
255
|
-
name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
|
256
|
-
- name: Setup Gemfile
|
257
|
-
if: ${{ matrix.rails != '5_2' }}
|
258
|
-
run: |
|
259
|
-
cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
260
|
-
cp ./version_v2.rb lib/arel_extensions/version.rb
|
261
|
-
cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
|
262
|
-
- name: bundle install
|
263
|
-
run: |
|
264
|
-
bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
|
265
|
-
bundle install
|
266
|
-
- name: Run test MySql
|
267
|
-
env:
|
268
|
-
DB_CONNECTION: mysql
|
269
|
-
DB_HOST: 127.0.0.1
|
270
|
-
DB_PORT: 3306
|
271
|
-
DB_DATABASE: arelx_test
|
272
|
-
DB_USERNAME: root
|
273
|
-
run: bundle exec rake test:mysql
|
274
|
-
|
275
|
-
job_test_mssql:
|
276
|
-
name: test mssql on linux
|
277
|
-
needs: job_build_gem
|
278
|
-
runs-on: ubuntu-latest
|
279
|
-
strategy:
|
280
|
-
fail-fast: false
|
281
|
-
matrix:
|
282
|
-
ruby: [3.1, 3.0, 2.7, 2.5, jruby-9.2, jruby-9.3]
|
283
|
-
rails: [7, 6_1, 6, 5_2]
|
284
|
-
exclude: [
|
285
|
-
{ruby: 3.1, rails: 6 },
|
286
|
-
{ruby: 3.1, rails: 5_2 },
|
287
|
-
{ruby: 3.0, rails: 6 },
|
288
|
-
{ruby: 3.0, rails: 5_2 },
|
289
|
-
{ruby: 2.7, rails: 5_2 },
|
290
|
-
{ruby: 2.5, rails: 7 },
|
291
|
-
{ruby: jruby-9.2, rails: 7 },
|
292
|
-
{ruby: jruby-9.2, rails: 6_1 },
|
293
|
-
{ruby: jruby-9.2, rails: 6 },
|
294
|
-
{ruby: jruby-9.3, rails: 7 },
|
295
|
-
{ruby: jruby-9.3, rails: 6_1 },
|
296
|
-
{ruby: jruby-9.3, rails: 6 },
|
297
|
-
]
|
298
|
-
steps:
|
299
|
-
- uses: actions/checkout@v2
|
300
|
-
- name: Set up Ruby
|
301
|
-
uses: ruby/setup-ruby@v1
|
302
|
-
with:
|
303
|
-
ruby-version: ${{ matrix.ruby }}
|
304
|
-
- name: Install FreeTDS
|
305
|
-
run: |
|
306
|
-
sudo apt-get update -q
|
307
|
-
sudo apt-get install -y freetds-dev
|
308
|
-
- name: Install MSSQL 2019
|
309
|
-
uses: potatoqualitee/mssqlsuite@v1
|
310
|
-
with:
|
311
|
-
install: sqlengine, sqlclient, sqlpackage, localdb
|
312
|
-
sa-password: Password12!
|
313
|
-
- name: Update system-wide gems
|
314
|
-
run: gem update --system
|
315
|
-
- name: Download gem from build job
|
316
|
-
uses: actions/download-artifact@v2
|
317
|
-
with:
|
318
|
-
name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
|
319
|
-
- name: Setup Gemfile
|
320
|
-
if: ${{ matrix.rails != '5_2' }}
|
321
|
-
run: |
|
322
|
-
cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
323
|
-
cp ./version_v2.rb lib/arel_extensions/version.rb
|
324
|
-
cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
|
325
|
-
- name: bundle install
|
326
|
-
run: |
|
327
|
-
bundle config set gemfile ./gemfiles/rails${{ matrix.rails }}.gemfile
|
328
|
-
bundle install
|
329
|
-
- name: Run test mssql
|
330
|
-
run: bundle exec rake test:mssql
|
331
|
-
|
332
|
-
job_test_windows:
|
333
|
-
name: test mssql on windows
|
334
|
-
needs: job_build_gem
|
335
|
-
runs-on: windows-latest
|
336
|
-
strategy:
|
337
|
-
fail-fast: false
|
338
|
-
matrix:
|
339
|
-
ruby: [3.1, 3.0, 2.7, 2.5]
|
340
|
-
rails: [7, 6_1, 6, 5_2]
|
341
|
-
exclude: [
|
342
|
-
{ruby: 3.1, rails: 6 },
|
343
|
-
{ruby: 3.1, rails: 5_2 },
|
344
|
-
{ruby: 3.0, rails: 6 },
|
345
|
-
{ruby: 3.0, rails: 5_2 },
|
346
|
-
{ruby: 2.7, rails: 5_2 },
|
347
|
-
{ruby: 2.5, rails: 7 },
|
348
|
-
{ruby: jruby-9.2, rails: 7 },
|
349
|
-
{ruby: jruby-9.2, rails: 6_1 },
|
350
|
-
{ruby: jruby-9.2, rails: 6 },
|
351
|
-
{ruby: jruby-9.3, rails: 7 },
|
352
|
-
{ruby: jruby-9.3, rails: 6_1 },
|
353
|
-
{ruby: jruby-9.3, rails: 6 },
|
354
|
-
]
|
355
|
-
steps:
|
356
|
-
- uses: actions/checkout@v2
|
357
|
-
- name: Install mssql
|
358
|
-
uses: potatoqualitee/mssqlsuite@v1
|
359
|
-
with:
|
360
|
-
install: sqlengine, sqlclient, sqlpackage, localdb
|
361
|
-
sa-password: Password12!
|
362
|
-
- name: Set up Ruby
|
363
|
-
uses: MSP-Greg/ruby-setup-ruby@win-ucrt-1
|
364
|
-
with:
|
365
|
-
ruby-version: ${{ matrix.ruby }}
|
366
|
-
- name: Install required packages on Windows
|
367
|
-
shell: cmd
|
368
|
-
run: |
|
369
|
-
ridk exec sh -c "pacman --sync --needed --noconfirm ${MINGW_PACKAGE_PREFIX}-gcc"
|
370
|
-
- name: Update system-wide gems
|
371
|
-
run: gem update --system
|
372
|
-
- name: Setup Gemfile
|
373
|
-
if: ${{ matrix.rails != '5_2' }}
|
374
|
-
run: |
|
375
|
-
cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
376
|
-
cp ./version_v2.rb lib/arel_extensions/version.rb
|
377
|
-
cp ./gemfiles/rails${{ matrix.rails }}.gemfile ./Gemfile
|
378
|
-
- name: bundle install
|
379
|
-
run: |
|
380
|
-
bundle config set gemfile .\gemfiles\rails${{ matrix.rails }}.gemfile
|
381
|
-
bundle install --verbose
|
382
|
-
- name: Download gem from build job
|
383
|
-
uses: actions/download-artifact@v2
|
384
|
-
with:
|
385
|
-
name: ${{ matrix.ruby }}-${{ matrix.rails }}-gem
|
386
|
-
- name: Install downloaded gem
|
387
|
-
run: gem install --local *.gem --verbose
|
388
|
-
- name: Run test mssql
|
389
|
-
run: bundle exec rake test:mssql
|
data/gemfiles/rails6.gemfile
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'rails', '~> 6.0.0'
|
4
|
-
|
5
|
-
|
6
|
-
group :development, :test do
|
7
|
-
gem 'activesupport', '~> 6.0.0'
|
8
|
-
gem 'activemodel', '~> 6.0.0'
|
9
|
-
gem 'activerecord', '~> 6.0.0'
|
10
|
-
|
11
|
-
gem 'sqlite3', '~> 1.4', platforms: [:mri]
|
12
|
-
gem 'mysql2', '0.5.2', platforms: [:mri]
|
13
|
-
gem 'pg', '< 1.0.0', platforms: [:mri]
|
14
|
-
|
15
|
-
gem 'tiny_tds', platforms: [:mri, :mingw, :x64_mingw, :mswin]
|
16
|
-
gem 'activerecord-sqlserver-adapter', '~> 6.0', platforms: [:mri, :mingw, :x64_mingw, :mswin]
|
17
|
-
|
18
|
-
gem 'ruby-oci8', platforms: [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
|
19
|
-
gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0' if ENV.has_key? 'ORACLE_HOME'
|
20
|
-
|
21
|
-
# for JRuby
|
22
|
-
gem 'activerecord-jdbc-adapter', github: 'jruby/activerecord-jdbc-adapter', tag: 'v60.4', platforms: :jruby
|
23
|
-
gem 'jdbc-sqlite3', platforms: :jruby
|
24
|
-
gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
|
25
|
-
gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
|
26
|
-
gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
|
27
|
-
end
|
28
|
-
|
29
|
-
gemspec path: '../'
|
data/gemfiles/rails6_1.gemfile
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'rails', '~> 6.1.0'
|
4
|
-
|
5
|
-
|
6
|
-
group :development, :test do
|
7
|
-
gem 'activesupport', '~> 6.1.0'
|
8
|
-
gem 'activemodel', '~> 6.1.0'
|
9
|
-
gem 'activerecord', '~> 6.1.0'
|
10
|
-
|
11
|
-
gem 'sqlite3', '~> 1.4', platforms: [:mri]
|
12
|
-
gem 'mysql2', '0.5.2', platforms: [:mri]
|
13
|
-
gem 'pg', '~> 1.1', platforms: [:mri]
|
14
|
-
|
15
|
-
gem 'tiny_tds', platforms: [:mri, :mingw, :x64_mingw, :mswin]
|
16
|
-
gem 'activerecord-sqlserver-adapter', '~> 6.1.0', platforms: [:mri, :mingw, :x64_mingw, :mswin]
|
17
|
-
|
18
|
-
gem 'ruby-oci8', platforms: [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
|
19
|
-
gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0' if ENV.has_key? 'ORACLE_HOME'
|
20
|
-
|
21
|
-
# for JRuby
|
22
|
-
gem 'activerecord-jdbc-adapter', github: 'jruby/activerecord-jdbc-adapter', tag: 'v61.1', platforms: :jruby
|
23
|
-
gem 'jdbc-sqlite3', platforms: :jruby
|
24
|
-
gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
|
25
|
-
gem 'activerecord-jdbcmysql-adapter', platforms: :jruby
|
26
|
-
gem 'activerecord-jdbcpostgresql-adapter', platforms: :jruby
|
27
|
-
end
|
28
|
-
|
29
|
-
gemspec path: '../'
|
data/gemfiles/rails7.gemfile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'rails', '~> 7.0.1'
|
4
|
-
|
5
|
-
|
6
|
-
group :development, :test do
|
7
|
-
gem 'activesupport', '~> 7.0.1'
|
8
|
-
gem 'activemodel', '~> 7.0.1'
|
9
|
-
gem 'activerecord', '~> 7.0.1'
|
10
|
-
|
11
|
-
gem 'sqlite3', '~> 1.4', platforms: [:mri]
|
12
|
-
gem 'mysql2', '0.5.2', platforms: [:mri]
|
13
|
-
gem 'pg', '~> 1.1', platforms: [:mri]
|
14
|
-
|
15
|
-
gem 'tiny_tds', platforms: [:mri, :mingw, :x64_mingw, :mswin]
|
16
|
-
gem 'activerecord-sqlserver-adapter', '~> 7.0.0.0', platforms: [:mri, :mingw, :x64_mingw, :mswin]
|
17
|
-
|
18
|
-
gem 'ruby-oci8', platforms: [:mri, :mswin, :mingw] if ENV.has_key? 'ORACLE_HOME'
|
19
|
-
gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.0' if ENV.has_key? 'ORACLE_HOME'
|
20
|
-
end
|
21
|
-
|
22
|
-
gemspec path: '../'
|
@@ -1,28 +0,0 @@
|
|
1
|
-
$:.push File.expand_path('../lib', __FILE__)
|
2
|
-
require 'arel_extensions/version'
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.name = 'arel_extensions'
|
6
|
-
s.version = ArelExtensions::VERSION
|
7
|
-
s.platform = Gem::Platform::RUBY
|
8
|
-
s.authors = ['Yann Azoury', 'Félix Bellanger', 'Julien Delporte']
|
9
|
-
s.email = ['yann.azoury@faveod.com', 'felix.bellanger@faveod.com', 'julien.delporte@faveod.com']
|
10
|
-
s.homepage = 'https://github.com/Faveod/arel-extensions'
|
11
|
-
s.description = 'Adds new features to Arel'
|
12
|
-
s.summary = 'Extending Arel'
|
13
|
-
s.license = 'MIT'
|
14
|
-
|
15
|
-
s.rdoc_options = ['--main', 'README.md']
|
16
|
-
s.extra_rdoc_files = ['MIT-LICENSE.txt', 'README.md', 'functions.html']
|
17
|
-
|
18
|
-
# Manifest
|
19
|
-
s.files = `git ls-files`.split("\n")
|
20
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
-
s.require_paths = ['lib']
|
22
|
-
|
23
|
-
s.add_dependency('arel', '>= 6.0')
|
24
|
-
|
25
|
-
s.add_development_dependency('minitest', '~> 5.9')
|
26
|
-
s.add_development_dependency('rdoc', '>= 6.3.1')
|
27
|
-
s.add_development_dependency('rake', '~> 12.3.3')
|
28
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
$:.push File.expand_path('../lib', __FILE__)
|
2
|
-
require 'arel_extensions/version'
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.name = 'arel_extensions'
|
6
|
-
s.version = ArelExtensions::VERSION
|
7
|
-
s.platform = Gem::Platform::RUBY
|
8
|
-
s.authors = ['Yann Azoury', 'Félix Bellanger', 'Julien Delporte']
|
9
|
-
s.email = ['yann.azoury@faveod.com', 'felix.bellanger@faveod.com', 'julien.delporte@faveod.com']
|
10
|
-
s.homepage = 'https://github.com/Faveod/arel-extensions'
|
11
|
-
s.description = 'Adds new features to Arel'
|
12
|
-
s.summary = 'Extending Arel'
|
13
|
-
s.license = 'MIT'
|
14
|
-
|
15
|
-
s.rdoc_options = ['--main', 'README.md']
|
16
|
-
s.extra_rdoc_files = ['MIT-LICENSE.txt', 'README.md', 'functions.html']
|
17
|
-
|
18
|
-
# Manifest
|
19
|
-
s.files = `git ls-files`.split("\n")
|
20
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
-
s.require_paths = ['lib']
|
22
|
-
|
23
|
-
s.add_dependency('activerecord', '>= 6.0')
|
24
|
-
|
25
|
-
s.add_development_dependency('minitest', '~> 5.9')
|
26
|
-
s.add_development_dependency('rdoc', '>= 6.3.1')
|
27
|
-
s.add_development_dependency('rake', '~> 12.3.3')
|
28
|
-
end
|
data/generate_gems.sh
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
|
2
|
-
#gem uninstall arel_extensions
|
3
|
-
|
4
|
-
# VERSION ~> 1
|
5
|
-
cp ./version_v1.rb lib/arel_extensions/version.rb
|
6
|
-
cp ./gemspecs/arel_extensions-v1.gemspec ./arel_extensions.gemspec
|
7
|
-
gem build ./arel_extensions.gemspec
|
8
|
-
|
9
|
-
# VERSION ~> 2
|
10
|
-
cp ./version_v2.rb lib/arel_extensions/version.rb
|
11
|
-
mv ./arel_extensions.gemspec ./arel_extensions.gemspec.bck
|
12
|
-
cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
13
|
-
gem build ./arel_extensions.gemspec
|
14
|
-
cp ./version_v1.rb lib/arel_extensions/version.rb
|
15
|
-
cp ./gemspecs/arel_extensions-v1.gemspec ./arel_extensions.gemspec
|
@@ -1,51 +0,0 @@
|
|
1
|
-
module ArelExtensions
|
2
|
-
|
3
|
-
#
|
4
|
-
# column_of
|
5
|
-
#
|
6
|
-
# Before the creation of these methods, getting the column name was done
|
7
|
-
# uniquely through the code found in `column_of_via_arel_table`.
|
8
|
-
#
|
9
|
-
# This turned out to be unreliable, most notably when using adapters that do
|
10
|
-
# not come with activerecord standard batteries. SQL Server is the most
|
11
|
-
# notorious example.
|
12
|
-
#
|
13
|
-
# Currently, we're using a needlessly complicated way to address this issue.
|
14
|
-
# Different versions of activerecord are behaving differently; the public APIs
|
15
|
-
# do not seem to come with any guarantees, so we need to be sure that we're
|
16
|
-
# coveing all these cases.
|
17
|
-
|
18
|
-
def self.column_of_via_arel_table(table_name, column_name)
|
19
|
-
Arel::Table.engine.connection.schema_cache.columns_hash(table_name)[column_name]
|
20
|
-
rescue NoMethodError
|
21
|
-
nil
|
22
|
-
rescue => e
|
23
|
-
warn("Warning: Unexpected exception caught while fetching column name for #{table_name}.#{column_name} in `column_of_via_arel_table`\n#{e.class}: #{e}")
|
24
|
-
nil
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.column_of(table_name, column_name)
|
28
|
-
pool = ActiveRecord::Base.connection.pool
|
29
|
-
use_arel_table = !ActiveRecord::Base.connected? || \
|
30
|
-
(pool.respond_to?(:schema_cache) && pool.schema_cache.nil?)
|
31
|
-
|
32
|
-
if use_arel_table
|
33
|
-
column_of_via_arel_table(table_name, column_name)
|
34
|
-
else
|
35
|
-
if pool.respond_to?(:pool_config)
|
36
|
-
pool.pool_config.schema_cache.columns_hash(table_name)[column_name]
|
37
|
-
elsif pool.respond_to?(:schema_cache)
|
38
|
-
pool.schema_cache.columns_hash(table_name)[column_name]
|
39
|
-
else
|
40
|
-
column_of_via_arel_table(table_name, column_name)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
rescue ActiveRecord::ConnectionNotEstablished
|
44
|
-
column_of_via_arel_table(table_name, column_name)
|
45
|
-
rescue ActiveRecord::StatementInvalid
|
46
|
-
nil
|
47
|
-
rescue => e
|
48
|
-
warn("Warning: Unexpected exception caught while fetching column name for #{table_name}.#{column_name} in `column_of`\n#{e.class}: #{e}")
|
49
|
-
nil
|
50
|
-
end
|
51
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module ArelExtensions
|
2
|
-
module Nodes
|
3
|
-
class AggregateFunction < Function
|
4
|
-
attr_accessor :order, :group
|
5
|
-
|
6
|
-
def initialize node, **opts
|
7
|
-
@order = Array(opts[:order]).map{|e| convert_to_node(e)}
|
8
|
-
@group = Array(opts[:group]).map{|e| convert_to_node(e)}
|
9
|
-
super [node]
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module ArelExtensions
|
2
|
-
module Visitors
|
3
|
-
# Convert date format in strftime syntax to whatever the RDBMs
|
4
|
-
# wants, based on the table of conversion +mapping+.
|
5
|
-
def self.strftime_to_format format, mapping
|
6
|
-
@mapping_regexps ||= {}
|
7
|
-
@mapping_regexps[mapping] ||=
|
8
|
-
Regexp.new(
|
9
|
-
mapping
|
10
|
-
.keys
|
11
|
-
.map{|k| Regexp.escape(k)}
|
12
|
-
.join('|')
|
13
|
-
)
|
14
|
-
|
15
|
-
regexp = @mapping_regexps[mapping]
|
16
|
-
s = StringScanner.new format
|
17
|
-
res = StringIO.new
|
18
|
-
while !s.eos?
|
19
|
-
res <<
|
20
|
-
case
|
21
|
-
when s.scan(regexp)
|
22
|
-
if v = mapping[s.matched]
|
23
|
-
v
|
24
|
-
else
|
25
|
-
# Should never happen.
|
26
|
-
s.matched
|
27
|
-
end
|
28
|
-
when s.scan(/[^%]+/)
|
29
|
-
s.matched
|
30
|
-
when s.scan(/./)
|
31
|
-
s.matched
|
32
|
-
end
|
33
|
-
end
|
34
|
-
res.string
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|