arel_toolkit 0.4.3 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/coverage.yml +48 -0
- data/.github/workflows/test.yml +68 -0
- data/.gitignore +3 -1
- data/.rubocop.yml +2 -0
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/Appraisals +4 -0
- data/CHANGELOG.md +49 -3
- data/Gemfile.lock +134 -84
- data/README.md +20 -3
- data/arel_toolkit.gemspec +3 -5
- data/bin/console +2 -1
- data/bin/setup +23 -2
- data/docker-compose.yml +11 -0
- data/gemfiles/active_record_6.gemfile +3 -3
- data/gemfiles/active_record_6.gemfile.lock +9 -7
- data/gemfiles/active_record_6_1.gemfile +7 -0
- data/gemfiles/active_record_6_1.gemfile.lock +263 -0
- data/gemfiles/arel_gems.gemfile.lock +9 -7
- data/gemfiles/default.gemfile.lock +9 -7
- data/lib/arel/enhance/context_enhancer/arel_table.rb +20 -0
- data/lib/arel/enhance/node.rb +20 -12
- data/lib/arel/enhance/visitor.rb +1 -1
- data/lib/arel/enhance.rb +2 -2
- data/lib/arel/extensions/conflict.rb +3 -3
- data/lib/arel/extensions/delete_statement.rb +19 -14
- data/lib/arel/extensions/infer.rb +2 -2
- data/lib/arel/extensions/insert_statement.rb +3 -3
- data/lib/arel/extensions/overlaps.rb +7 -1
- data/lib/arel/extensions/table.rb +7 -2
- data/lib/arel/extensions/transaction.rb +9 -9
- data/lib/arel/extensions/tree_manager.rb +0 -5
- data/lib/arel/extensions/update_statement.rb +8 -22
- data/lib/arel/sql_to_arel/pg_query_visitor/frame_options.rb +37 -5
- data/lib/arel/sql_to_arel/pg_query_visitor.rb +430 -521
- data/lib/arel/transformer/prefix_schema_name.rb +5 -3
- data/lib/arel/transformer.rb +0 -1
- data/lib/arel_toolkit/version.rb +1 -1
- metadata +15 -12
- data/.github/workflows/develop.yml +0 -90
- data/.github/workflows/master.yml +0 -67
- data/lib/arel/transformer/remove_active_record_info.rb +0 -40
@@ -119,17 +119,19 @@ module Arel
|
|
119
119
|
|
120
120
|
# https://www.rubydoc.info/github/rubyworks/facets/String:unquote
|
121
121
|
def unquote_string(string)
|
122
|
+
s = string.dup
|
123
|
+
|
122
124
|
case string[0, 1]
|
123
125
|
when "'", '"', '`'
|
124
|
-
|
126
|
+
s[0] = ''
|
125
127
|
end
|
126
128
|
|
127
129
|
case string[-1, 1]
|
128
130
|
when "'", '"', '`'
|
129
|
-
|
131
|
+
s[-1] = ''
|
130
132
|
end
|
131
133
|
|
132
|
-
|
134
|
+
s
|
133
135
|
end
|
134
136
|
|
135
137
|
def database_object_mapping
|
data/lib/arel/transformer.rb
CHANGED
data/lib/arel_toolkit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arel_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- maarten
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 5.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pg
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '2.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '2.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 2.
|
159
|
+
version: 2.4.1
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 2.
|
166
|
+
version: 2.4.1
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: database_cleaner
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -400,12 +400,13 @@ extensions:
|
|
400
400
|
extra_rdoc_files: []
|
401
401
|
files:
|
402
402
|
- ".codeclimate.yml"
|
403
|
-
- ".github/workflows/
|
404
|
-
- ".github/workflows/
|
403
|
+
- ".github/workflows/coverage.yml"
|
404
|
+
- ".github/workflows/test.yml"
|
405
405
|
- ".gitignore"
|
406
406
|
- ".rspec"
|
407
407
|
- ".rubocop.yml"
|
408
408
|
- ".ruby-version"
|
409
|
+
- ".tool-versions"
|
409
410
|
- Appraisals
|
410
411
|
- CHANGELOG.md
|
411
412
|
- CODE_OF_CONDUCT.md
|
@@ -419,12 +420,15 @@ files:
|
|
419
420
|
- benchmark.rb
|
420
421
|
- bin/console
|
421
422
|
- bin/setup
|
423
|
+
- docker-compose.yml
|
422
424
|
- ext/pg_result_init/extconf.rb
|
423
425
|
- ext/pg_result_init/pg_result_init.c
|
424
426
|
- ext/pg_result_init/pg_result_init.h
|
425
427
|
- gemfiles/.bundle/config
|
426
428
|
- gemfiles/active_record_6.gemfile
|
427
429
|
- gemfiles/active_record_6.gemfile.lock
|
430
|
+
- gemfiles/active_record_6_1.gemfile
|
431
|
+
- gemfiles/active_record_6_1.gemfile.lock
|
428
432
|
- gemfiles/arel_gems.gemfile
|
429
433
|
- gemfiles/arel_gems.gemfile.lock
|
430
434
|
- gemfiles/default.gemfile
|
@@ -570,7 +574,6 @@ files:
|
|
570
574
|
- lib/arel/sql_to_arel/result.rb
|
571
575
|
- lib/arel/transformer.rb
|
572
576
|
- lib/arel/transformer/prefix_schema_name.rb
|
573
|
-
- lib/arel/transformer/remove_active_record_info.rb
|
574
577
|
- lib/arel/transformer/replace_table_with_subquery.rb
|
575
578
|
- lib/arel_toolkit.rb
|
576
579
|
- lib/arel_toolkit/version.rb
|
@@ -593,7 +596,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
593
596
|
- !ruby/object:Gem::Version
|
594
597
|
version: '0'
|
595
598
|
requirements: []
|
596
|
-
rubygems_version: 3.
|
599
|
+
rubygems_version: 3.1.6
|
597
600
|
signing_key:
|
598
601
|
specification_version: 4
|
599
602
|
summary: Collection of tools for Arel
|
@@ -1,90 +0,0 @@
|
|
1
|
-
name: CI - develop
|
2
|
-
on:
|
3
|
-
push:
|
4
|
-
branches-ignore:
|
5
|
-
- master
|
6
|
-
|
7
|
-
jobs:
|
8
|
-
rspec:
|
9
|
-
name: RSpec - ${{ matrix.title }}
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
strategy:
|
12
|
-
fail-fast: false
|
13
|
-
matrix:
|
14
|
-
checkout: [branch, master]
|
15
|
-
include:
|
16
|
-
- checkout: branch
|
17
|
-
ref: null
|
18
|
-
title: current branch
|
19
|
-
rebase: false
|
20
|
-
codeclimate: true
|
21
|
-
- checkout: master
|
22
|
-
ref: master
|
23
|
-
title: merge with master
|
24
|
-
rebase: true
|
25
|
-
codeclimate: false
|
26
|
-
|
27
|
-
services:
|
28
|
-
postgres:
|
29
|
-
options: >-
|
30
|
-
--health-cmd pg_isready
|
31
|
-
--health-interval 10s
|
32
|
-
--health-timeout 5s
|
33
|
-
--health-retries 5
|
34
|
-
image: postgres:10.10
|
35
|
-
ports:
|
36
|
-
- 5432:5432
|
37
|
-
env:
|
38
|
-
POSTGRES_DB: arel_toolkit_test
|
39
|
-
POSTGRES_USER: postgres
|
40
|
-
steps:
|
41
|
-
- uses: actions/checkout@v1
|
42
|
-
with:
|
43
|
-
ref: ${{ matrix.ref }}
|
44
|
-
|
45
|
-
# Based on
|
46
|
-
# https://discourse.drone.io/t/planned-change-to-git-clone-logic/1165
|
47
|
-
- name: Rebase
|
48
|
-
if: matrix.rebase
|
49
|
-
run: |
|
50
|
-
export GIT_AUTHOR_NAME=${CI_COMMIT_AUTHOR_NAME=GithubCI}
|
51
|
-
export GIT_AUTHOR_EMAIL=${CI_COMMIT_AUTHOR_EMAIL=ci@github.comm}
|
52
|
-
export GIT_COMMITTER_NAME=${GIT_AUTHOR_NAME}
|
53
|
-
export GIT_COMMITTER_EMAIL=${GIT_AUTHOR_EMAIL}
|
54
|
-
git fetch origin $GITHUB_REF
|
55
|
-
git rebase $GITHUB_SHA
|
56
|
-
|
57
|
-
- name: Set up Ruby 2.5.x
|
58
|
-
uses: actions/setup-ruby@v1
|
59
|
-
with:
|
60
|
-
ruby-version: 2.5.x
|
61
|
-
|
62
|
-
- name: Setup
|
63
|
-
run: |
|
64
|
-
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
65
|
-
chmod +x ./cc-test-reporter
|
66
|
-
./cc-test-reporter before-build
|
67
|
-
|
68
|
-
sudo apt-get install -y libpq-dev
|
69
|
-
|
70
|
-
gem install bundler
|
71
|
-
|
72
|
-
bundle install --jobs 4 --retry 3
|
73
|
-
bundle exec appraisal install
|
74
|
-
|
75
|
-
bundle exec rake clean
|
76
|
-
bundle exec rake compile
|
77
|
-
|
78
|
-
- name: RSpec
|
79
|
-
run: |
|
80
|
-
bundle exec appraisal rspec --force-color
|
81
|
-
|
82
|
-
- name: Report to codeclimate
|
83
|
-
if: always() && matrix.codeclimate
|
84
|
-
shell: bash
|
85
|
-
env:
|
86
|
-
JOB_STATUS: ${{ job.status == 'Success' }}
|
87
|
-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
88
|
-
run: |
|
89
|
-
EXIT_CODE=$([[ "$JOB_STATUS" == true ]] && echo 0 || echo 1)
|
90
|
-
./cc-test-reporter after-build --exit-code $EXIT_CODE
|
@@ -1,67 +0,0 @@
|
|
1
|
-
name: CI - master
|
2
|
-
on:
|
3
|
-
push:
|
4
|
-
branches:
|
5
|
-
- master
|
6
|
-
|
7
|
-
jobs:
|
8
|
-
rspec:
|
9
|
-
name: RSpec - master
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
|
12
|
-
services:
|
13
|
-
postgres:
|
14
|
-
options: >-
|
15
|
-
--health-cmd pg_isready
|
16
|
-
--health-interval 10s
|
17
|
-
--health-timeout 5s
|
18
|
-
--health-retries 5
|
19
|
-
image: postgres:10.10
|
20
|
-
ports:
|
21
|
-
- 5432:5432
|
22
|
-
env:
|
23
|
-
POSTGRES_DB: arel_toolkit_test
|
24
|
-
POSTGRES_USER: postgres
|
25
|
-
steps:
|
26
|
-
- uses: actions/checkout@v1
|
27
|
-
|
28
|
-
- name: Set up Ruby 2.5.x
|
29
|
-
uses: actions/setup-ruby@v1
|
30
|
-
with:
|
31
|
-
ruby-version: 2.5.x
|
32
|
-
|
33
|
-
- name: Setup
|
34
|
-
run: |
|
35
|
-
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
36
|
-
chmod +x ./cc-test-reporter
|
37
|
-
./cc-test-reporter before-build
|
38
|
-
|
39
|
-
sudo apt-get install -y libpq-dev
|
40
|
-
|
41
|
-
gem install bundler
|
42
|
-
|
43
|
-
bundle install --jobs 4 --retry 3
|
44
|
-
bundle exec appraisal install
|
45
|
-
|
46
|
-
bundle exec rake clean
|
47
|
-
bundle exec rake compile
|
48
|
-
|
49
|
-
- name: RSpec
|
50
|
-
run: |
|
51
|
-
bundle exec appraisal rspec --force-color
|
52
|
-
|
53
|
-
- name: Report to codeclimate
|
54
|
-
if: always()
|
55
|
-
shell: bash
|
56
|
-
env:
|
57
|
-
JOB_STATUS: ${{ job.status == 'Success' }}
|
58
|
-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
59
|
-
run: |
|
60
|
-
EXIT_CODE=$([[ "$JOB_STATUS" == true ]] && echo 0 || echo 1)
|
61
|
-
./cc-test-reporter after-build --exit-code $EXIT_CODE
|
62
|
-
|
63
|
-
- name: Upload coverage to GitHub pages
|
64
|
-
uses: maxheld83/ghpages@v0.2.1
|
65
|
-
env:
|
66
|
-
BUILD_DIR: ./coverage
|
67
|
-
GH_PAT: ${{ secrets.GH_PAT }}
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module Arel
|
2
|
-
module Transformer
|
3
|
-
class RemoveActiveRecordInfo
|
4
|
-
class << self
|
5
|
-
def call(arel, next_middleware)
|
6
|
-
tree = Arel.enhance(arel)
|
7
|
-
|
8
|
-
tree.query(class: Arel::Table).each do |node|
|
9
|
-
node['type_caster'].remove
|
10
|
-
end
|
11
|
-
|
12
|
-
tree.query(class: Arel::Nodes::BindParam).each do |node|
|
13
|
-
node.replace(
|
14
|
-
cast_for_database(node.object.value.value_for_database),
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
next_middleware.call tree.object
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def cast_for_database(value)
|
24
|
-
case value
|
25
|
-
when String
|
26
|
-
Arel::Nodes.build_quoted(value)
|
27
|
-
when Integer
|
28
|
-
value
|
29
|
-
when TrueClass
|
30
|
-
Arel::Nodes::TypeCast.new(Arel::Nodes::Quoted.new('t'), 'bool')
|
31
|
-
when FalseClass
|
32
|
-
Arel::Nodes::TypeCast.new(Arel::Nodes::Quoted.new('f'), 'bool')
|
33
|
-
else
|
34
|
-
raise "Unknown value cast `#{value}` with class `#{value.class}`"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|