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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/coverage.yml +48 -0
  3. data/.github/workflows/test.yml +68 -0
  4. data/.gitignore +3 -1
  5. data/.rubocop.yml +2 -0
  6. data/.ruby-version +1 -1
  7. data/.tool-versions +1 -0
  8. data/Appraisals +4 -0
  9. data/CHANGELOG.md +49 -3
  10. data/Gemfile.lock +134 -84
  11. data/README.md +20 -3
  12. data/arel_toolkit.gemspec +3 -5
  13. data/bin/console +2 -1
  14. data/bin/setup +23 -2
  15. data/docker-compose.yml +11 -0
  16. data/gemfiles/active_record_6.gemfile +3 -3
  17. data/gemfiles/active_record_6.gemfile.lock +9 -7
  18. data/gemfiles/active_record_6_1.gemfile +7 -0
  19. data/gemfiles/active_record_6_1.gemfile.lock +263 -0
  20. data/gemfiles/arel_gems.gemfile.lock +9 -7
  21. data/gemfiles/default.gemfile.lock +9 -7
  22. data/lib/arel/enhance/context_enhancer/arel_table.rb +20 -0
  23. data/lib/arel/enhance/node.rb +20 -12
  24. data/lib/arel/enhance/visitor.rb +1 -1
  25. data/lib/arel/enhance.rb +2 -2
  26. data/lib/arel/extensions/conflict.rb +3 -3
  27. data/lib/arel/extensions/delete_statement.rb +19 -14
  28. data/lib/arel/extensions/infer.rb +2 -2
  29. data/lib/arel/extensions/insert_statement.rb +3 -3
  30. data/lib/arel/extensions/overlaps.rb +7 -1
  31. data/lib/arel/extensions/table.rb +7 -2
  32. data/lib/arel/extensions/transaction.rb +9 -9
  33. data/lib/arel/extensions/tree_manager.rb +0 -5
  34. data/lib/arel/extensions/update_statement.rb +8 -22
  35. data/lib/arel/sql_to_arel/pg_query_visitor/frame_options.rb +37 -5
  36. data/lib/arel/sql_to_arel/pg_query_visitor.rb +430 -521
  37. data/lib/arel/transformer/prefix_schema_name.rb +5 -3
  38. data/lib/arel/transformer.rb +0 -1
  39. data/lib/arel_toolkit/version.rb +1 -1
  40. metadata +15 -12
  41. data/.github/workflows/develop.yml +0 -90
  42. data/.github/workflows/master.yml +0 -67
  43. 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
- string[0] = ''
126
+ s[0] = ''
125
127
  end
126
128
 
127
129
  case string[-1, 1]
128
130
  when "'", '"', '`'
129
- string[-1] = ''
131
+ s[-1] = ''
130
132
  end
131
133
 
132
- string
134
+ s
133
135
  end
134
136
 
135
137
  def database_object_mapping
@@ -1,6 +1,5 @@
1
1
  require_relative './transformer/prefix_schema_name'
2
2
  require_relative './transformer/replace_table_with_subquery'
3
- require_relative './transformer/remove_active_record_info'
4
3
 
5
4
  module Arel
6
5
  module Transformer
@@ -1,3 +1,3 @@
1
1
  module ArelToolkit
2
- VERSION = '0.4.3'.freeze
2
+ VERSION = '0.4.7'.freeze
3
3
  end
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.3
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: 2020-11-09 00:00:00.000000000 Z
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: '0'
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: '0'
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: 1.2.0
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: 1.2.0
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.2.0
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.2.0
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/develop.yml"
404
- - ".github/workflows/master.yml"
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.0.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