arel_extensions 1.4.0 → 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/.gitignore +6 -7
- data/.rubocop.yml +3 -67
- 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 +28 -2
- data/README.md +90 -239
- data/Rakefile +30 -48
- data/TODO +1 -0
- data/appveyor.yml +22 -60
- data/arel_extensions.gemspec +14 -13
- data/functions.html +3 -3
- data/gemfiles/rails3.gemfile +10 -10
- data/gemfiles/rails4.gemfile +29 -0
- data/gemfiles/rails5_0.gemfile +29 -0
- data/gemfiles/rails5_1_4.gemfile +14 -14
- data/gemfiles/rails5_2.gemfile +14 -16
- 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 -15
- data/lib/arel_extensions/boolean_functions.rb +14 -53
- data/lib/arel_extensions/common_sql_functions.rb +17 -16
- data/lib/arel_extensions/comparators.rb +28 -27
- data/lib/arel_extensions/date_duration.rb +13 -17
- data/lib/arel_extensions/insert_manager.rb +15 -18
- data/lib/arel_extensions/math.rb +53 -55
- 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 +19 -20
- data/lib/arel_extensions/nodes/cast.rb +8 -10
- data/lib/arel_extensions/nodes/ceil.rb +1 -1
- data/lib/arel_extensions/nodes/coalesce.rb +4 -3
- 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 +26 -42
- 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 -52
- 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 +2 -1
- 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 +5 -3
- 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/then.rb +1 -1
- data/lib/arel_extensions/nodes/trim.rb +6 -4
- 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 +5 -19
- 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 -59
- 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 +191 -422
- data/lib/arel_extensions/visitors/mysql.rb +212 -350
- data/lib/arel_extensions/visitors/oracle.rb +178 -220
- data/lib/arel_extensions/visitors/oracle12.rb +31 -18
- data/lib/arel_extensions/visitors/postgresql.rb +173 -256
- data/lib/arel_extensions/visitors/sqlite.rb +126 -140
- data/lib/arel_extensions/visitors/to_sql.rb +237 -298
- data/lib/arel_extensions/visitors.rb +62 -83
- data/lib/arel_extensions.rb +31 -224
- data/test/database.yml +7 -15
- data/test/helper.rb +18 -0
- data/test/real_db_test.rb +117 -120
- data/test/support/fake_record.rb +3 -9
- data/test/test_comparators.rb +17 -14
- data/test/visitors/test_bulk_insert_oracle.rb +11 -11
- data/test/visitors/test_bulk_insert_sqlite.rb +13 -12
- data/test/visitors/test_bulk_insert_to_sql.rb +13 -11
- 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 +366 -709
- data/test/with_ar/insert_agnostic_test.rb +21 -27
- data/test/with_ar/test_bulk_sqlite.rb +16 -17
- 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 +34 -43
- data/.github/workflows/publish.yml +0 -29
- data/.github/workflows/release.yml +0 -30
- data/.github/workflows/ruby.yml +0 -399
- data/CONTRIBUTING.md +0 -102
- data/NEWS.md +0 -78
- data/bin/build +0 -15
- data/bin/compose +0 -6
- data/bin/publish +0 -8
- data/dev/arelx.dockerfile +0 -44
- data/dev/compose.yaml +0 -71
- data/dev/postgres.dockerfile +0 -5
- data/dev/rbenv +0 -189
- data/gemfiles/rails4_2.gemfile +0 -38
- data/gemfiles/rails5.gemfile +0 -29
- data/gemfiles/rails6.gemfile +0 -33
- data/gemfiles/rails6_1.gemfile +0 -33
- data/gemfiles/rails7.gemfile +0 -33
- data/gemfiles/rails7_1.gemfile +0 -33
- data/gemfiles/rails7_2.gemfile +0 -33
- data/gemspecs/arel_extensions-v1.gemspec +0 -27
- data/gemspecs/arel_extensions-v2.gemspec +0 -27
- data/generate_gems.sh +0 -15
- data/lib/arel_extensions/aliases.rb +0 -14
- data/lib/arel_extensions/helpers.rb +0 -62
- data/lib/arel_extensions/nodes/aggregate_function.rb +0 -13
- data/lib/arel_extensions/nodes/formatted_date.rb +0 -42
- data/lib/arel_extensions/nodes/rollup.rb +0 -36
- data/lib/arel_extensions/nodes/select.rb +0 -10
- 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 -74
- data/version_v1.rb +0 -3
- data/version_v2.rb +0 -3
@@ -1,29 +0,0 @@
|
|
1
|
-
name: "Publish Gems"
|
2
|
-
on:
|
3
|
-
release:
|
4
|
-
types: [published]
|
5
|
-
|
6
|
-
jobs:
|
7
|
-
publish_gems:
|
8
|
-
name: Publish to Rubygems
|
9
|
-
runs-on: ubuntu-latest
|
10
|
-
steps:
|
11
|
-
- uses: actions/checkout@v3
|
12
|
-
- name: setup ruby 3.2
|
13
|
-
uses: ruby/setup-ruby@v1
|
14
|
-
with:
|
15
|
-
ruby-version: 3.2
|
16
|
-
- name: Fetch Github Release Asset
|
17
|
-
uses: dsaltares/fetch-gh-release-asset@master
|
18
|
-
with:
|
19
|
-
file: "arel_extensions.*.gem"
|
20
|
-
regex: true
|
21
|
-
token: ${{ secrets.GITHUB_TOKEN }}
|
22
|
-
- name: List gems
|
23
|
-
run: ls -l *.gem
|
24
|
-
- name: Release Gems
|
25
|
-
uses: cadwallion/publish-rubygems-action@master
|
26
|
-
env:
|
27
|
-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
28
|
-
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
29
|
-
RELEASE_COMMAND: bin/publish
|
@@ -1,30 +0,0 @@
|
|
1
|
-
name: Release
|
2
|
-
on:
|
3
|
-
workflow_run:
|
4
|
-
workflows: ["Build and Test"]
|
5
|
-
branches: [master]
|
6
|
-
types:
|
7
|
-
- completed
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
build_gems:
|
11
|
-
name: Build Gemfiles
|
12
|
-
runs-on: ubuntu-latest
|
13
|
-
steps:
|
14
|
-
- uses: actions/checkout@v3
|
15
|
-
- name: setup ruby 3.2
|
16
|
-
uses: ruby/setup-ruby@v1
|
17
|
-
with:
|
18
|
-
ruby-version: 3.2
|
19
|
-
- name: build gems
|
20
|
-
run: |
|
21
|
-
bin/build
|
22
|
-
- name: release
|
23
|
-
uses: softprops/action-gh-release@v1
|
24
|
-
with:
|
25
|
-
tag_name: ${{ github.ref }}-${{ steps.vars.outputs.sha_short }}
|
26
|
-
draft: true
|
27
|
-
files: |
|
28
|
-
./arel_extensions-*.gem
|
29
|
-
env:
|
30
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
data/.github/workflows/ruby.yml
DELETED
@@ -1,399 +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:
|
7
|
-
push:
|
8
|
-
branches:
|
9
|
-
- master
|
10
|
-
pull_request:
|
11
|
-
branches:
|
12
|
-
- master
|
13
|
-
|
14
|
-
jobs:
|
15
|
-
job_test_to_sql:
|
16
|
-
name: test to_sql
|
17
|
-
runs-on: ubuntu-latest
|
18
|
-
strategy:
|
19
|
-
fail-fast: false
|
20
|
-
matrix:
|
21
|
-
versions:
|
22
|
-
[
|
23
|
-
{ ruby: "3.3", rails: 7_2, arelx: 2 },
|
24
|
-
{ ruby: "3.3", rails: 7_1, arelx: 2 },
|
25
|
-
{ ruby: "3.3", rails: 7, arelx: 2 },
|
26
|
-
{ ruby: "3.3", rails: 6_1, arelx: 2 },
|
27
|
-
{ ruby: "3.2", rails: 7_2, arelx: 2 },
|
28
|
-
{ ruby: "3.2", rails: 7_1, arelx: 2 },
|
29
|
-
{ ruby: "3.2", rails: 7, arelx: 2 },
|
30
|
-
{ ruby: "3.2", rails: 6, arelx: 2 },
|
31
|
-
{ ruby: "3.2", rails: 6_1, arelx: 2 },
|
32
|
-
{ ruby: "3.1", rails: 7_2, arelx: 2 },
|
33
|
-
{ ruby: "3.1", rails: 7_1, arelx: 2 },
|
34
|
-
{ ruby: "3.1", rails: 7, arelx: 2 },
|
35
|
-
{ ruby: "3.1", rails: 6_1, arelx: 2 },
|
36
|
-
{ ruby: "3.1", rails: 6, arelx: 2 },
|
37
|
-
{ ruby: "3.0", rails: 7_1, arelx: 2 },
|
38
|
-
{ ruby: "3.0", rails: 7, arelx: 2 },
|
39
|
-
{ ruby: "3.0", rails: 6_1, arelx: 2 },
|
40
|
-
{ ruby: "2.7", rails: 7_1, arelx: 2 },
|
41
|
-
{ ruby: "2.7", rails: 7, arelx: 2 },
|
42
|
-
{ ruby: "2.7", rails: 6_1, arelx: 2 },
|
43
|
-
{ ruby: "2.7", rails: 6, arelx: 2 },
|
44
|
-
{ ruby: "2.7", rails: 5_2, arelx: 1 },
|
45
|
-
{ ruby: "2.7", rails: 4_2, arelx: 1 },
|
46
|
-
{ ruby: "2.5", rails: 6_1, arelx: 2 },
|
47
|
-
{ ruby: "2.5", rails: 6, arelx: 2 },
|
48
|
-
{ ruby: "2.5", rails: 5_2, arelx: 1 },
|
49
|
-
{ ruby: "2.5", rails: 4_2, arelx: 1 },
|
50
|
-
{ ruby: jruby-9.2, rails: 6_1, arelx: 2 },
|
51
|
-
{ ruby: jruby-9.2, rails: 6, arelx: 2 },
|
52
|
-
{ ruby: jruby-9.2, rails: 5_2, arelx: 1 },
|
53
|
-
{ ruby: jruby-9.3, rails: 6_1, arelx: 2 },
|
54
|
-
{ ruby: jruby-9.3, rails: 6, arelx: 2 },
|
55
|
-
{ ruby: jruby-9.3, rails: 5_2, arelx: 1 },
|
56
|
-
]
|
57
|
-
steps:
|
58
|
-
- uses: actions/checkout@v2
|
59
|
-
- name: Set up Ruby
|
60
|
-
uses: ruby/setup-ruby@v1
|
61
|
-
with:
|
62
|
-
ruby-version: ${{ matrix.versions.ruby }}
|
63
|
-
- name: Install FreeTDS
|
64
|
-
run: |
|
65
|
-
sudo apt-get update -q
|
66
|
-
sudo apt-get install -y freetds-dev
|
67
|
-
- name: Setup Gemfile
|
68
|
-
run: |
|
69
|
-
cp ./gemspecs/arel_extensions-v${{ matrix.versions.arelx }}.gemspec ./arel_extensions.gemspec
|
70
|
-
cp ./version_v${{ matrix.versions.arelx }}.rb lib/arel_extensions/version.rb
|
71
|
-
cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
|
72
|
-
- name: bundle install
|
73
|
-
run: |
|
74
|
-
bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
|
75
|
-
bundle install
|
76
|
-
- name: Run test to_sql
|
77
|
-
run: bundle exec rake test:to_sql
|
78
|
-
|
79
|
-
job_test_sqlite:
|
80
|
-
name: test sqlite
|
81
|
-
runs-on: ubuntu-latest
|
82
|
-
strategy:
|
83
|
-
fail-fast: false
|
84
|
-
matrix:
|
85
|
-
versions:
|
86
|
-
[
|
87
|
-
{ ruby: "3.3", rails: 7_2, arelx: 2 },
|
88
|
-
{ ruby: "3.3", rails: 7_1, arelx: 2 },
|
89
|
-
{ ruby: "3.3", rails: 7, arelx: 2 },
|
90
|
-
{ ruby: "3.3", rails: 6_1, arelx: 2 },
|
91
|
-
{ ruby: "3.2", rails: 7_2, arelx: 2 },
|
92
|
-
{ ruby: "3.2", rails: 7_1, arelx: 2 },
|
93
|
-
{ ruby: "3.2", rails: 7, arelx: 2 },
|
94
|
-
{ ruby: "3.2", rails: 6_1, arelx: 2 },
|
95
|
-
{ ruby: "3.2", rails: 6, arelx: 2 },
|
96
|
-
{ ruby: "3.1", rails: 7_2, arelx: 2 },
|
97
|
-
{ ruby: "3.1", rails: 7_1, arelx: 2 },
|
98
|
-
{ ruby: "3.1", rails: 7, arelx: 2 },
|
99
|
-
{ ruby: "3.1", rails: 6, arelx: 2 },
|
100
|
-
{ ruby: "3.1", rails: 6_1, arelx: 2 },
|
101
|
-
{ ruby: "3.0", rails: 7_1, arelx: 2 },
|
102
|
-
{ ruby: "3.0", rails: 7, arelx: 2 },
|
103
|
-
{ ruby: "3.0", rails: 6_1, arelx: 2 },
|
104
|
-
{ ruby: "2.7", rails: 7_1, arelx: 2 },
|
105
|
-
{ ruby: "2.7", rails: 7, arelx: 2 },
|
106
|
-
{ ruby: "2.7", rails: 6_1, arelx: 2 },
|
107
|
-
{ ruby: "2.7", rails: 6, arelx: 2 },
|
108
|
-
{ ruby: "2.7", rails: 5_2, arelx: 1 },
|
109
|
-
{ ruby: "2.7", rails: 4_2, arelx: 1 },
|
110
|
-
{ ruby: "2.5", rails: 6_1, arelx: 2 },
|
111
|
-
{ ruby: "2.5", rails: 6, arelx: 2 },
|
112
|
-
{ ruby: "2.5", rails: 5_2, arelx: 1 },
|
113
|
-
{ ruby: "2.5", rails: 4_2, arelx: 1 },
|
114
|
-
{ ruby: jruby-9.2, rails: 6_1, arelx: 2 },
|
115
|
-
{ ruby: jruby-9.2, rails: 6, arelx: 2 },
|
116
|
-
{ ruby: jruby-9.2, rails: 5_2, arelx: 1 },
|
117
|
-
{ ruby: jruby-9.2, rails: 4_2, arelx: 1 },
|
118
|
-
{ ruby: jruby-9.3, rails: 6_1, arelx: 2 },
|
119
|
-
{ ruby: jruby-9.3, rails: 6, arelx: 2 },
|
120
|
-
{ ruby: jruby-9.3, rails: 5_2, arelx: 1 },
|
121
|
-
]
|
122
|
-
steps:
|
123
|
-
- uses: actions/checkout@v2
|
124
|
-
- name: Set up Ruby
|
125
|
-
uses: ruby/setup-ruby@v1
|
126
|
-
with:
|
127
|
-
ruby-version: ${{ matrix.versions.ruby }}
|
128
|
-
- name: Install FreeTDS
|
129
|
-
run: |
|
130
|
-
sudo apt-get update -q
|
131
|
-
sudo apt-get install -y freetds-dev
|
132
|
-
- name: Setup Gemfile
|
133
|
-
run: |
|
134
|
-
cp ./gemspecs/arel_extensions-v${{ matrix.versions.arelx }}.gemspec ./arel_extensions.gemspec
|
135
|
-
cp ./version_v${{ matrix.versions.arelx }}.rb lib/arel_extensions/version.rb
|
136
|
-
cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
|
137
|
-
- name: bundle install
|
138
|
-
run: |
|
139
|
-
bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
|
140
|
-
bundle install
|
141
|
-
- name: Run test sqlite
|
142
|
-
run: bundle exec rake test:sqlite
|
143
|
-
|
144
|
-
job_test_postgres:
|
145
|
-
name: test postgres
|
146
|
-
runs-on: ubuntu-latest
|
147
|
-
strategy:
|
148
|
-
fail-fast: false
|
149
|
-
matrix:
|
150
|
-
versions: [
|
151
|
-
{ ruby: "3.3", rails: 7_2, arelx: 2 },
|
152
|
-
{ ruby: "3.3", rails: 7_1, arelx: 2 },
|
153
|
-
{ ruby: "3.3", rails: 7, arelx: 2 },
|
154
|
-
{ ruby: "3.3", rails: 6_1, arelx: 2 },
|
155
|
-
{ ruby: "3.2", rails: 7_2, arelx: 2 },
|
156
|
-
{ ruby: "3.2", rails: 7_1, arelx: 2 },
|
157
|
-
{ ruby: "3.2", rails: 7, arelx: 2 },
|
158
|
-
{ ruby: "3.2", rails: 6_1, arelx: 2 },
|
159
|
-
# { ruby: "3.2", rails: 6, arelx: 2 }, # cannot test > undefined symbol: rb_tainted_str_new2
|
160
|
-
{ ruby: "3.1", rails: 7_2, arelx: 2 },
|
161
|
-
{ ruby: "3.1", rails: 7_1, arelx: 2 },
|
162
|
-
{ ruby: "3.1", rails: 7, arelx: 2 },
|
163
|
-
{ ruby: "3.1", rails: 6_1, arelx: 2 },
|
164
|
-
{ ruby: "3.1", rails: 6, arelx: 2 },
|
165
|
-
{ ruby: "3.0", rails: 7_1, arelx: 2 },
|
166
|
-
{ ruby: "3.0", rails: 7, arelx: 2 },
|
167
|
-
{ ruby: "3.0", rails: 6_1, arelx: 2 },
|
168
|
-
{ ruby: "2.7", rails: 7_1, arelx: 2 },
|
169
|
-
{ ruby: "2.7", rails: 7, arelx: 2 },
|
170
|
-
{ ruby: "2.7", rails: 6_1, arelx: 2 },
|
171
|
-
{ ruby: "2.7", rails: 6, arelx: 2 },
|
172
|
-
{ ruby: "2.7", rails: 5_2, arelx: 1 },
|
173
|
-
{ ruby: "2.7", rails: 4_2, arelx: 1 },
|
174
|
-
{ ruby: "2.5", rails: 6_1, arelx: 2 },
|
175
|
-
{ ruby: "2.5", rails: 6, arelx: 2 },
|
176
|
-
{ ruby: "2.5", rails: 5_2, arelx: 1 },
|
177
|
-
{ ruby: "2.5", rails: 4_2, arelx: 1 },
|
178
|
-
{ ruby: jruby-9.2, rails: 6_1, arelx: 2 },
|
179
|
-
{ ruby: jruby-9.2, rails: 6, arelx: 2 },
|
180
|
-
{ ruby: jruby-9.2, rails: 5_2, arelx: 1 },
|
181
|
-
{ ruby: jruby-9.2, rails: 4_2, arelx: 1 },
|
182
|
-
{ ruby: jruby-9.3, rails: 6_1, arelx: 2 },
|
183
|
-
{ ruby: jruby-9.3, rails: 6, arelx: 2 },
|
184
|
-
{ ruby: jruby-9.3, rails: 5_2, arelx: 1 },
|
185
|
-
]
|
186
|
-
steps:
|
187
|
-
- uses: actions/checkout@v2
|
188
|
-
# PostgreSQL requires locales to be installed on the system to be able
|
189
|
-
# to do time and currency conversions at runtime.
|
190
|
-
#
|
191
|
-
# That's why we're not launching it as a service; pre-built images
|
192
|
-
# lack loaclization.
|
193
|
-
#
|
194
|
-
# After we install locales, we'll install PostgreSQL binaries and start
|
195
|
-
# the service.
|
196
|
-
- name: setup locale
|
197
|
-
run: |
|
198
|
-
sudo locale-gen fr_FR.utf8
|
199
|
-
sudo update-locale
|
200
|
-
- name: setup postgres 11
|
201
|
-
run: |
|
202
|
-
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
|
203
|
-
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
|
204
|
-
sudo apt update
|
205
|
-
sudo apt -y install postgresql-11
|
206
|
-
sudo systemctl enable postgresql
|
207
|
-
sudo systemctl start postgresql
|
208
|
-
sudo su -c "psql -c \"alter user postgres with password 'secret'\"" postgres
|
209
|
-
sudo su -c "createdb arelx_test" postgres
|
210
|
-
- name: Set up Ruby
|
211
|
-
uses: ruby/setup-ruby@v1
|
212
|
-
with:
|
213
|
-
ruby-version: ${{ matrix.versions.ruby }}
|
214
|
-
- name: Install FreeTDS
|
215
|
-
run: |
|
216
|
-
sudo apt-get update -q
|
217
|
-
sudo apt-get install -y freetds-dev
|
218
|
-
- name: Setup Gemfile
|
219
|
-
run: |
|
220
|
-
cp ./gemspecs/arel_extensions-v${{ matrix.versions.arelx }}.gemspec ./arel_extensions.gemspec
|
221
|
-
cp ./version_v${{ matrix.versions.arelx }}.rb lib/arel_extensions/version.rb
|
222
|
-
cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
|
223
|
-
- name: bundle install
|
224
|
-
run: |
|
225
|
-
bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
|
226
|
-
bundle install
|
227
|
-
- name: Run test Postgres
|
228
|
-
env:
|
229
|
-
PGHOST: localhost
|
230
|
-
PGUSER: postgres
|
231
|
-
run: bundle exec rake test:postgresql
|
232
|
-
|
233
|
-
job_test_mysql:
|
234
|
-
name: test mysql
|
235
|
-
runs-on: ubuntu-latest
|
236
|
-
strategy:
|
237
|
-
fail-fast: false
|
238
|
-
matrix:
|
239
|
-
versions: [
|
240
|
-
{ ruby: "3.3", rails: 7_2, arelx: 2 },
|
241
|
-
{ ruby: "3.3", rails: 7_1, arelx: 2 },
|
242
|
-
{ ruby: "3.3", rails: 7, arelx: 2 },
|
243
|
-
{ ruby: "3.3", rails: 6_1, arelx: 2 },
|
244
|
-
{ ruby: "3.2", rails: 7_2, arelx: 2 },
|
245
|
-
{ ruby: "3.2", rails: 7_1, arelx: 2 },
|
246
|
-
{ ruby: "3.2", rails: 7, arelx: 2 },
|
247
|
-
{ ruby: "3.2", rails: 6_1, arelx: 2 },
|
248
|
-
# { ruby: "3.2", rails: 6, arelx: 2 }, # cannot test > undefined symbol: rb_tainted_str_new2
|
249
|
-
{ ruby: "3.1", rails: 7_2, arelx: 2 },
|
250
|
-
{ ruby: "3.1", rails: 7_1, arelx: 2 },
|
251
|
-
{ ruby: "3.1", rails: 7, arelx: 2 },
|
252
|
-
{ ruby: "3.1", rails: 6_1, arelx: 2 },
|
253
|
-
{ ruby: "3.1", rails: 6, arelx: 2 },
|
254
|
-
{ ruby: "3.0", rails: 7_1, arelx: 2 },
|
255
|
-
{ ruby: "3.0", rails: 7, arelx: 2 },
|
256
|
-
{ ruby: "3.0", rails: 6_1, arelx: 2 },
|
257
|
-
{ ruby: "2.7", rails: 7_1, arelx: 2 },
|
258
|
-
{ ruby: "2.7", rails: 7, arelx: 2 },
|
259
|
-
{ ruby: "2.7", rails: 6_1, arelx: 2 },
|
260
|
-
{ ruby: "2.7", rails: 6, arelx: 2 },
|
261
|
-
{ ruby: "2.7", rails: 5_2, arelx: 1 },
|
262
|
-
{ ruby: "2.7", rails: 4_2, arelx: 1 },
|
263
|
-
{ ruby: "2.5", rails: 6_1, arelx: 2 },
|
264
|
-
{ ruby: "2.5", rails: 6, arelx: 2 },
|
265
|
-
{ ruby: "2.5", rails: 5_2, arelx: 1 },
|
266
|
-
{ ruby: "2.5", rails: 4_2, arelx: 1 },
|
267
|
-
{ ruby: jruby-9.2, rails: 6_1, arelx: 2 },
|
268
|
-
{ ruby: jruby-9.2, rails: 6, arelx: 2 },
|
269
|
-
{ ruby: jruby-9.2, rails: 5_2, arelx: 1 },
|
270
|
-
{ ruby: jruby-9.2, rails: 4_2, arelx: 1 },
|
271
|
-
{ ruby: jruby-9.3, rails: 6_1, arelx: 2 },
|
272
|
-
{ ruby: jruby-9.3, rails: 6, arelx: 2 },
|
273
|
-
{ ruby: jruby-9.3, rails: 5_2, arelx: 1 },
|
274
|
-
]
|
275
|
-
services:
|
276
|
-
mysql:
|
277
|
-
image: mysql:5.7
|
278
|
-
env:
|
279
|
-
MYSQL_ALLOW_EMPTY_PASSWORD: true
|
280
|
-
MYSQL_USERNAME: root
|
281
|
-
MYSQL_DATABASE: arelx_test
|
282
|
-
ports:
|
283
|
-
- 3306:3306
|
284
|
-
options: >-
|
285
|
-
--health-cmd="mysqladmin ping"
|
286
|
-
--health-interval=10s
|
287
|
-
--health-timeout=5s
|
288
|
-
--health-retries=3
|
289
|
-
steps:
|
290
|
-
- uses: actions/checkout@v2
|
291
|
-
- name: Set up Ruby
|
292
|
-
uses: ruby/setup-ruby@v1
|
293
|
-
with:
|
294
|
-
ruby-version: ${{ matrix.versions.ruby }}
|
295
|
-
- name: Install FreeTDS
|
296
|
-
run: |
|
297
|
-
sudo apt-get update -q
|
298
|
-
sudo apt-get install -y freetds-dev
|
299
|
-
- name: Setup Gemfile
|
300
|
-
run: |
|
301
|
-
cp ./gemspecs/arel_extensions-v${{ matrix.versions.arelx }}.gemspec ./arel_extensions.gemspec
|
302
|
-
cp ./version_v${{ matrix.versions.arelx }}.rb lib/arel_extensions/version.rb
|
303
|
-
cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
|
304
|
-
- name: bundle install
|
305
|
-
run: |
|
306
|
-
bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
|
307
|
-
bundle install
|
308
|
-
- name: Run test MySql
|
309
|
-
env:
|
310
|
-
DB_CONNECTION: mysql
|
311
|
-
DB_HOST: 127.0.0.1
|
312
|
-
DB_PORT: 3306
|
313
|
-
DB_DATABASE: arelx_test
|
314
|
-
DB_USERNAME: root
|
315
|
-
run: bundle exec rake test:mysql
|
316
|
-
|
317
|
-
job_test_mssql:
|
318
|
-
name: test mssql on linux
|
319
|
-
runs-on: ubuntu-latest
|
320
|
-
strategy:
|
321
|
-
fail-fast: false
|
322
|
-
matrix:
|
323
|
-
versions: [
|
324
|
-
{ ruby: "3.3", rails: 7_1, arelx: 2 },
|
325
|
-
{ ruby: "3.3", rails: 7, arelx: 2 },
|
326
|
-
{ ruby: "3.3", rails: 6_1, arelx: 2 },
|
327
|
-
{ ruby: "3.3", rails: 6, arelx: 2 },
|
328
|
-
{ ruby: "3.2", rails: 7_1, arelx: 2 },
|
329
|
-
{ ruby: "3.2", rails: 7, arelx: 2 },
|
330
|
-
{ ruby: "3.2", rails: 6_1, arelx: 2 },
|
331
|
-
{ ruby: "3.2", rails: 6, arelx: 2 },
|
332
|
-
{ ruby: "3.1", rails: 7_1, arelx: 2 },
|
333
|
-
{ ruby: "3.1", rails: 7, arelx: 2 },
|
334
|
-
{ ruby: "3.1", rails: 6_1, arelx: 2 },
|
335
|
-
{ ruby: "3.1", rails: 6, arelx: 2 },
|
336
|
-
{ ruby: "3.0", rails: 7, arelx: 2 },
|
337
|
-
{ ruby: "3.0", rails: 6_1, arelx: 2 },
|
338
|
-
{ ruby: "3.0", rails: 6, arelx: 2 },
|
339
|
-
{ ruby: "2.7", rails: 6_1, arelx: 2 },
|
340
|
-
{ ruby: "2.7", rails: 6, arelx: 2 },
|
341
|
-
{ ruby: "2.7", rails: 5_2, arelx: 1 },
|
342
|
-
{ ruby: "2.7", rails: 4_2, arelx: 1 },
|
343
|
-
{ ruby: "2.5", rails: 6_1, arelx: 2 },
|
344
|
-
{ ruby: "2.5", rails: 6, arelx: 2 },
|
345
|
-
{ ruby: "2.5", rails: 5_2, arelx: 1 },
|
346
|
-
{ ruby: "2.5", rails: 4_2, arelx: 1 },
|
347
|
-
# {ruby: jruby-9.2, rails: 6_1, arelx: 2},
|
348
|
-
# {ruby: jruby-9.2, rails: 6, arelx: 2},
|
349
|
-
{ ruby: jruby-9.2, rails: 5_2, arelx: 1 },
|
350
|
-
{ ruby: jruby-9.2, rails: 4_2, arelx: 1 },
|
351
|
-
# See comments on 9.4 to understand why these are disabled for now.
|
352
|
-
# {ruby: jruby-9.3, rails: 6_1, arelx: 2},
|
353
|
-
# {ruby: jruby-9.3, rails: 6, arelx: 2},
|
354
|
-
# {ruby: jruby-9.3, rails: 5_2, arelx: 1},
|
355
|
-
{ ruby: jruby-9.4, rails: 7_1, arelx: 2 },
|
356
|
-
{ ruby: jruby-9.4, rails: 7, arelx: 2 },
|
357
|
-
#
|
358
|
-
# 6 and 6.1 don't work because of a bug in the alt adapter
|
359
|
-
# https://github.com/JesseChavez/activerecord-jdbc-adapter/issues/16
|
360
|
-
# {ruby: jruby-9.4, rails: 6_1, arelx: 2},
|
361
|
-
# {ruby: jruby-9.4, rails: 6, arelx: 2},
|
362
|
-
#
|
363
|
-
# < 5.2 don't work because of a deeper issue.
|
364
|
-
# {ruby: jruby-9.4, rails: 5_2, arelx: 1},
|
365
|
-
]
|
366
|
-
mssql: [2017, 2019]
|
367
|
-
steps:
|
368
|
-
- uses: actions/checkout@v2
|
369
|
-
- name: Set up Ruby
|
370
|
-
uses: ruby/setup-ruby@v1
|
371
|
-
with:
|
372
|
-
ruby-version: ${{ matrix.versions.ruby }}
|
373
|
-
- name: Install FreeTDS
|
374
|
-
run: |
|
375
|
-
sudo apt-get update -q
|
376
|
-
sudo apt-get install -y freetds-dev
|
377
|
-
- name: Install MSSQL ${{ matrix.mssql }}
|
378
|
-
uses: potatoqualitee/mssqlsuite@v1.5.1
|
379
|
-
with:
|
380
|
-
version: ${{ matrix.mssql }}
|
381
|
-
install: sqlengine, sqlclient, sqlpackage, localdb
|
382
|
-
sa-password: Password12!
|
383
|
-
- name: Setup Gemfile
|
384
|
-
run: |
|
385
|
-
cp ./gemspecs/arel_extensions-v${{ matrix.versions.arelx }}.gemspec ./arel_extensions.gemspec
|
386
|
-
cp ./version_v${{ matrix.versions.arelx }}.rb lib/arel_extensions/version.rb
|
387
|
-
cp ./gemfiles/rails${{ matrix.versions.rails }}.gemfile ./Gemfile
|
388
|
-
- name: bundle install
|
389
|
-
run: |
|
390
|
-
bundle config set gemfile ./gemfiles/rails${{ matrix.versions.rails }}.gemfile
|
391
|
-
bundle install
|
392
|
-
- name: Run test mssql [mri]
|
393
|
-
if: ${{ !contains(matrix.versions.ruby, 'jruby') }}
|
394
|
-
run: bundle exec rake test:mssql
|
395
|
-
- name: Run test mssql [jruby]
|
396
|
-
if: ${{ contains(matrix.versions.ruby, 'jruby') }}
|
397
|
-
run: |
|
398
|
-
curl -LO https://github.com/microsoft/mssql-jdbc/releases/download/v8.4.1/mssql-jdbc-8.4.1.jre11.jar
|
399
|
-
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/NEWS.md
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
# News
|
2
|
-
|
3
|
-
## Release v2.2.0/v1.4.0
|
4
|
-
|
5
|
-
- MS SQL: restrict date-quoting to Arel <= 6 (Rails 4.2)
|
6
|
-
- MS SQL: turn on warnings on requires only when gem is found
|
7
|
-
- Rails: 7.2 support for mysql, postgres, and sqlite.
|
8
|
-
- Attributes: deprecate `==` and `!=`. They're causing issues with
|
9
|
-
`active_record`, and they're not sanitary.
|
10
|
-
|
11
|
-
## Release v2.1.11/v1.3.11
|
12
|
-
|
13
|
-
- MS SQL: turn on warnings on requires only when necessary.
|
14
|
-
|
15
|
-
## Release v2.1.10/v1.3.10
|
16
|
-
|
17
|
-
- MS SQL: add support for jruby 9.4 via [activerecord-jdbc-alt-adapter](https://rubygems.org/gems/activerecord-jdbc-alt-adapter/)
|
18
|
-
|
19
|
-
## Release v2.1.9/v1.3.9
|
20
|
-
|
21
|
-
### Bug Fixes
|
22
|
-
|
23
|
-
- Postgres:
|
24
|
-
- Datetime formatting in postgres now behaves like mysql: if the target
|
25
|
-
timezone is a string, we automatically consider that you're trying to
|
26
|
-
convert from `UTC`.
|
27
|
-
- Datetime casting will now automatically ask for a
|
28
|
-
`timestamp without timezone`, also aligning with the expected befavior
|
29
|
-
in mysql. This also makes casting work better with timezone conversion,
|
30
|
-
especially if you don't pass the timezone from which you're converting
|
31
|
-
to.
|
32
|
-
```ruby
|
33
|
-
scope
|
34
|
-
.select(Arel.quoted('2022-02-01 10:42:00')
|
35
|
-
.cast(:datetime)
|
36
|
-
.format_date('%Y/%m/%d %H:%M:%S', 'Europe/Paris')
|
37
|
-
.as('res'))
|
38
|
-
```
|
39
|
-
Will produce:
|
40
|
-
```sql
|
41
|
-
SELECT TO_CHAR(
|
42
|
-
CAST('2022-02-01 10:42:00' AS timestamp without time zone) AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Paris',
|
43
|
-
'YYYY/MM/DD HH24:MI:SS'
|
44
|
-
)
|
45
|
-
AS "res"
|
46
|
-
-- …
|
47
|
-
```
|
48
|
-
|
49
|
-
## Release v2.1.7/v1.3.7
|
50
|
-
|
51
|
-
### New Features
|
52
|
-
|
53
|
-
- `o.format_date` as an alternative to `o.format`
|
54
|
-
The actual behavior of `format` is inconsistent across DB vendors: in mysql we
|
55
|
-
can format dates and numbers with it, and in the other ones we only format
|
56
|
-
dates.
|
57
|
-
|
58
|
-
We're planning on normalizing this behavior. We want `format` to "cleverly"
|
59
|
-
format dates or numbers, and `format_date` / `format_number` to strictly
|
60
|
-
format dates / numbers.
|
61
|
-
|
62
|
-
The introduction of `format_date` is the first step in this direction.
|
63
|
-
|
64
|
-
## Release v2.1.6/v1.3.6
|
65
|
-
|
66
|
-
### Bug Fixes
|
67
|
-
|
68
|
-
- This used to fail.
|
69
|
-
```
|
70
|
-
Arel.when(a).then(b).format('%Y-%m-%d')
|
71
|
-
```
|
72
|
-
|
73
|
-
### New Features
|
74
|
-
|
75
|
-
- `o.present`, a synonym for `o.not_blank`
|
76
|
-
- `o.coalesce_blank(a, b, c)`
|
77
|
-
- `o.if_present`, if the value is `null` or blank, then it returns `null`,
|
78
|
-
otherwise, it returns the value. Inspired by rails' `presence`.
|
data/bin/build
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#! /usr/bin/env sh
|
2
|
-
set -e
|
3
|
-
|
4
|
-
# VERSION ~> 1
|
5
|
-
echo "Packaging v1"
|
6
|
-
cp ./version_v1.rb lib/arel_extensions/version.rb
|
7
|
-
cp ./gemspecs/arel_extensions-v1.gemspec ./arel_extensions.gemspec
|
8
|
-
gem build ./arel_extensions.gemspec
|
9
|
-
|
10
|
-
# VERSION ~> 2
|
11
|
-
echo "Packaging v2"
|
12
|
-
cp ./version_v2.rb lib/arel_extensions/version.rb
|
13
|
-
cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
14
|
-
gem build ./arel_extensions.gemspec
|
15
|
-
|
data/bin/compose
DELETED