sorbet-rails 0.7.5 → 0.7.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +1 -1
  3. data/.github/workflows/publish-gem.yml +7 -1
  4. data/Gemfile +0 -2
  5. data/README.md +11 -1
  6. data/lib/sorbet-rails/model_plugins/active_record_querying.rb +25 -1
  7. data/lib/sorbet-rails/model_utils.rb +14 -7
  8. data/lib/sorbet-rails/rails_mixins/custom_finder_methods.rb +4 -0
  9. data/sorbet-rails.gemspec +1 -1
  10. data/spec/generators/sorbet_test_cases.rb +9 -0
  11. data/spec/support/v5.2/Gemfile.lock +1 -1
  12. data/spec/support/v5.2/sorbet_test_cases.rb +9 -0
  13. data/spec/support/v6.0/Gemfile.lock +1 -1
  14. data/spec/support/v6.0/sorbet_test_cases.rb +9 -0
  15. data/spec/support/v6.1/sorbet_test_cases.rb +9 -0
  16. data/spec/test_data/v5.2/expected_attachment.rbi +12 -6
  17. data/spec/test_data/v5.2/expected_blob.rbi +12 -6
  18. data/spec/test_data/v5.2/expected_headmaster.rbi +12 -6
  19. data/spec/test_data/v5.2/expected_internal_metadata.rbi +12 -6
  20. data/spec/test_data/v5.2/expected_potion.rbi +12 -6
  21. data/spec/test_data/v5.2/expected_robe.rbi +12 -6
  22. data/spec/test_data/v5.2/expected_schema_migration.rbi +12 -6
  23. data/spec/test_data/v5.2/expected_school.rbi +12 -6
  24. data/spec/test_data/v5.2/expected_spell/habtm_spell_books.rbi +12 -6
  25. data/spec/test_data/v5.2/expected_spell.rbi +12 -6
  26. data/spec/test_data/v5.2/expected_spell_book/habtm_spells.rbi +12 -6
  27. data/spec/test_data/v5.2/expected_spell_book.rbi +12 -6
  28. data/spec/test_data/v5.2/expected_squib.rbi +12 -6
  29. data/spec/test_data/v5.2/expected_subject/habtm_wizards.rbi +12 -6
  30. data/spec/test_data/v5.2/expected_subject.rbi +12 -6
  31. data/spec/test_data/v5.2/expected_wand.rbi +12 -6
  32. data/spec/test_data/v5.2/expected_wizard/habtm_subjects.rbi +12 -6
  33. data/spec/test_data/v5.2/expected_wizard.rbi +12 -6
  34. data/spec/test_data/v5.2/expected_wizard_wo_spellbook.rbi +12 -6
  35. data/spec/test_data/v6.0/expected_attachment.rbi +12 -6
  36. data/spec/test_data/v6.0/expected_blob.rbi +12 -6
  37. data/spec/test_data/v6.0/expected_headmaster.rbi +12 -6
  38. data/spec/test_data/v6.0/expected_internal_metadata.rbi +12 -6
  39. data/spec/test_data/v6.0/expected_potion.rbi +12 -6
  40. data/spec/test_data/v6.0/expected_robe.rbi +12 -6
  41. data/spec/test_data/v6.0/expected_schema_migration.rbi +12 -6
  42. data/spec/test_data/v6.0/expected_school.rbi +12 -6
  43. data/spec/test_data/v6.0/expected_spell/habtm_spell_books.rbi +12 -6
  44. data/spec/test_data/v6.0/expected_spell.rbi +12 -6
  45. data/spec/test_data/v6.0/expected_spell_book/habtm_spells.rbi +12 -6
  46. data/spec/test_data/v6.0/expected_spell_book.rbi +12 -6
  47. data/spec/test_data/v6.0/expected_squib.rbi +12 -6
  48. data/spec/test_data/v6.0/expected_subject/habtm_wizards.rbi +12 -6
  49. data/spec/test_data/v6.0/expected_subject.rbi +12 -6
  50. data/spec/test_data/v6.0/expected_wand.rbi +12 -6
  51. data/spec/test_data/v6.0/expected_wizard/habtm_subjects.rbi +12 -6
  52. data/spec/test_data/v6.0/expected_wizard.rbi +12 -6
  53. data/spec/test_data/v6.0/expected_wizard_wo_spellbook.rbi +12 -6
  54. data/spec/test_data/v6.1/expected_attachment.rbi +12 -6
  55. data/spec/test_data/v6.1/expected_blob.rbi +12 -6
  56. data/spec/test_data/v6.1/expected_headmaster.rbi +12 -6
  57. data/spec/test_data/v6.1/expected_internal_metadata.rbi +12 -6
  58. data/spec/test_data/v6.1/expected_potion.rbi +12 -6
  59. data/spec/test_data/v6.1/expected_record.rbi +12 -6
  60. data/spec/test_data/v6.1/expected_robe.rbi +12 -6
  61. data/spec/test_data/v6.1/expected_schema_migration.rbi +12 -6
  62. data/spec/test_data/v6.1/expected_school.rbi +12 -6
  63. data/spec/test_data/v6.1/expected_spell/habtm_spell_books.rbi +12 -6
  64. data/spec/test_data/v6.1/expected_spell.rbi +12 -6
  65. data/spec/test_data/v6.1/expected_spell_book/habtm_spells.rbi +12 -6
  66. data/spec/test_data/v6.1/expected_spell_book.rbi +12 -6
  67. data/spec/test_data/v6.1/expected_squib.rbi +12 -6
  68. data/spec/test_data/v6.1/expected_subject/habtm_wizards.rbi +12 -6
  69. data/spec/test_data/v6.1/expected_subject.rbi +12 -6
  70. data/spec/test_data/v6.1/expected_variant_record.rbi +12 -6
  71. data/spec/test_data/v6.1/expected_wand.rbi +12 -6
  72. data/spec/test_data/v6.1/expected_wizard/habtm_subjects.rbi +12 -6
  73. data/spec/test_data/v6.1/expected_wizard.rbi +12 -6
  74. data/spec/test_data/v6.1/expected_wizard_wo_spellbook.rbi +12 -6
  75. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19c59c20c90b7bc42d394b78ba48351d8e39c0721707e8463e337ca8141efe0b
4
- data.tar.gz: 30e0524281e51eb3614c346dbb67d966df524c7b2873b29967442924e525a64d
3
+ metadata.gz: c089b34f04fa829aa30f1e844626e4ffe72f95f4adb9a3690250287ae626af4f
4
+ data.tar.gz: 7e7afb8c3de657085ea4fce31584bbd324f27b57c66520f74967ada5ffee24dc
5
5
  SHA512:
6
- metadata.gz: a53b6bb92d2f307dc64682b42cdefb5badff876c65328d56bed5511c996e7c7d89ad9b07a25287d5bb8e212224283f80a98b30b8da92d5bd513ddfca7a6fd4a4
7
- data.tar.gz: 2745eb20e8f3058105f23b5b159e837da6f64e382860aa68f85dc49b5acfdae83d697e73daa54baf06aacb059fb5e3904921fbaaba93255c7379a35a4c1add8f
6
+ metadata.gz: eded78f1d240d92dfa8d52849846897f430756324e5999ec86ce04f595dc7f39906b8d145e7e30836bfa77cece8ddb26d80087dcfc26e3ca01c691efa320af74
7
+ data.tar.gz: 5f0bbab68508ed1cd968e2dcb098268cac25a29c917a5cb2517bc024f69ee27bada1e180f57cb54e9dff4d3964847f3d74084c886c0a8546d26f1a7cd5cb5dce
@@ -15,7 +15,6 @@ jobs:
15
15
 
16
16
  env:
17
17
  RAILS_VERSION: ${{ matrix.rails }}
18
- CI: true
19
18
 
20
19
  steps:
21
20
  - uses: actions/checkout@v2
@@ -24,3 +23,4 @@ jobs:
24
23
  ruby-version: ${{ matrix.ruby }}
25
24
  # bundler-cache: true -- this messes up some dynamic constants
26
25
  - run: "./spec/bin/run_spec.sh"
26
+ - run: bundle exec srb tc
@@ -11,10 +11,16 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
 
13
13
  env:
14
- CI: true
14
+ RAILS_VERSION: 6.0
15
15
 
16
16
  steps:
17
17
  - uses: actions/checkout@v2
18
+ - uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: 2.7
21
+ # bundler-cache: true -- this messes up some dynamic constants
22
+ - run: "./spec/bin/run_spec.sh"
23
+ - run: bundle exec srb tc
18
24
  - name: Release Gem
19
25
  uses: dawidd6/action-publish-gem@v1
20
26
  with:
data/Gemfile CHANGED
@@ -2,8 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rspec-core', '~> 3.8.0'
6
-
7
5
  group :test do
8
6
  gem 'simplecov', require: false
9
7
  gem 'codecov', require: false
data/README.md CHANGED
@@ -9,6 +9,8 @@ This gem adds a few Rake tasks to generate Ruby Interface (RBI) files for dynami
9
9
 
10
10
  `sorbet-rails` supports Rails 5+ or later.
11
11
 
12
+ **Notice**: we automatically creates a new release on Rubygems with every merges to the master branch
13
+
12
14
  **Notice**: we no longer support Rails 4.2. [Version 0.5.6](https://github.com/chanzuckerberg/sorbet-rails/releases/tag/v0.5.6) is the last version supporting Rails 4.2.
13
15
 
14
16
  ## Initial Setup
@@ -409,8 +411,16 @@ Model.unscoped.scoping do … end
409
411
 
410
412
  ### `select` with a block
411
413
 
412
- The [`select` method](https://apidock.com/rails/v4.0.2/ActiveRecord/QueryMethods/select) in Rails has two modes: it can be given a list of symbols, in which case rails will only return the given columns from the database, or it can be given a block, in which case it acts like [`Enumerable.select`](https://ruby-doc.org/core-2.6.4/Enumerable.html) and returns an array. We have chosen to support the first use case. If you want to pass a block to `select`, you can simply call `to_a` before you do. Note that this would be done within the `select` call anyway, so the performance penalty will be minimal.
414
+ The [`select` method](https://apidock.com/rails/v4.0.2/ActiveRecord/QueryMethods/select) in Rails has two modes: it can be given a list of symbols, in which case rails will only return the given columns from the database, or it can be given a block, in which case it acts like [`Enumerable.select`](https://ruby-doc.org/core-2.6.4/Enumerable.html) and returns an array.
415
+
416
+ We have chosen to support `select` with a block as the primary use case, since it is a more prevalent use of this method. We provide `select_columns` as an alternative if you want to select a list of columns.
413
417
 
418
+ ```
419
+ Model.select { |record| record.id > 1} # valid, returns an array
420
+ Model.select_columns(:id, :name) # valid, returns an association
421
+
422
+ Model.select(:id, :name) # sorbet error, use `select_column` instead
423
+ ```
414
424
  ### `flatten` an array of relation
415
425
 
416
426
  When you call `flatten` on an array of ActiveRecord::Relation, sorbet [doesn't recognize](https://github.com/sorbet/sorbet/issues/2767) that it will flatten the relation and return an array of model. The work around is to call `to_a` on the relation first.
@@ -25,7 +25,8 @@ class SorbetRails::ModelPlugins::ActiveRecordQuerying < SorbetRails::ModelPlugin
25
25
  # <Model>::Relation class.
26
26
  # rails/activerecord/lib/active_record/querying.rb
27
27
  model_query_relation_methods = [
28
- :select, :reselect, :order, :reorder, :group, :limit, :offset, :joins, :left_joins, :left_outer_joins,
28
+ # :select,
29
+ :reselect, :order, :reorder, :group, :limit, :offset, :joins, :left_joins, :left_outer_joins,
29
30
  :where, :rewhere, :preload, :extract_associated, :eager_load, :includes, :from, :lock, :readonly, :or,
30
31
  :having, :create_with, :distinct, :references, :none, :unscope, :optimizer_hints, :merge, :except, :only,
31
32
  ]
@@ -39,6 +40,29 @@ class SorbetRails::ModelPlugins::ActiveRecordQuerying < SorbetRails::ModelPlugin
39
40
  builtin_query_method: true,
40
41
  ) if exists_class_method?(method_name)
41
42
  end
43
+ if exists_class_method?("select")
44
+ # `select` can be used with a block to return an array, or with a list of column name
45
+ # to return a relation object that can be chained.
46
+ # I've seen usage of `select` with a block more often than with a list of column name.
47
+ # here we define select as taking a block, and add a `select_column` method for the other usage
48
+ add_relation_query_method(
49
+ root,
50
+ "select",
51
+ parameters: [
52
+ Parameter.new("&block", type: "T.proc.params(e: #{self.model_class_name}).returns(T::Boolean)"),
53
+ ],
54
+ builtin_query_method: true,
55
+ custom_return_value: "T::Array[#{self.model_class_name}]",
56
+ )
57
+ add_relation_query_method(
58
+ root,
59
+ "select_columns", # select_column is injected by sorbet-rails
60
+ parameters: [
61
+ Parameter.new("*args", type: "T.any(String, Symbol)"),
62
+ ],
63
+ builtin_query_method: true,
64
+ )
65
+ end
42
66
 
43
67
  add_relation_query_method(
44
68
  root,
@@ -90,9 +90,16 @@ module SorbetRails::ModelUtils
90
90
  # where, limit, etc and not something like a named scope. It should likely
91
91
  # only be set to `true` when called from the ActiveRecordQuerying plugin.
92
92
  builtin_query_method: T::Boolean,
93
+ custom_return_value: T.nilable(String),
93
94
  ).void
94
95
  }
95
- def add_relation_query_method(root, method_name, parameters: nil, builtin_query_method: false)
96
+ def add_relation_query_method(
97
+ root,
98
+ method_name,
99
+ parameters: nil,
100
+ builtin_query_method: false,
101
+ custom_return_value: nil
102
+ )
96
103
  # a relation querying method will be available on
97
104
  # - model (as a class method)
98
105
  # - activerecord relation
@@ -114,14 +121,14 @@ module SorbetRails::ModelUtils
114
121
  relation_module_rbi.create_method(
115
122
  method_name,
116
123
  parameters: parameters,
117
- return_type: self.model_relation_class_name,
124
+ return_type: custom_return_value || self.model_relation_class_name,
118
125
  )
119
126
 
120
127
  assoc_relation_module_rbi = root.create_module(self.model_query_methods_returning_assoc_relation_module_name)
121
128
  assoc_relation_module_rbi.create_method(
122
129
  method_name,
123
130
  parameters: parameters,
124
- return_type: assoc_return_value,
131
+ return_type: custom_return_value || assoc_return_value,
125
132
  )
126
133
  else
127
134
  # force generating these methods because sorbet's hidden-definitions generate & override them
@@ -129,7 +136,7 @@ module SorbetRails::ModelUtils
129
136
  model_class_rbi.create_method(
130
137
  method_name,
131
138
  parameters: parameters,
132
- return_type: self.model_relation_class_name,
139
+ return_type: custom_return_value || self.model_relation_class_name,
133
140
  class_method: true,
134
141
  )
135
142
 
@@ -137,21 +144,21 @@ module SorbetRails::ModelUtils
137
144
  model_relation_rbi.create_method(
138
145
  method_name,
139
146
  parameters: parameters,
140
- return_type: self.model_relation_class_name,
147
+ return_type: custom_return_value || self.model_relation_class_name,
141
148
  )
142
149
 
143
150
  model_assoc_relation_rbi = root.create_class(self.model_assoc_relation_class_name)
144
151
  model_assoc_relation_rbi.create_method(
145
152
  method_name,
146
153
  parameters: parameters,
147
- return_type: assoc_return_value,
154
+ return_type: custom_return_value || assoc_return_value,
148
155
  )
149
156
 
150
157
  collection_proxy_rbi = root.create_class(self.model_assoc_proxy_class_name)
151
158
  collection_proxy_rbi.create_method(
152
159
  method_name,
153
160
  parameters: parameters,
154
- return_type: assoc_return_value,
161
+ return_type: custom_return_value || assoc_return_value,
155
162
  )
156
163
  end
157
164
  end
@@ -13,6 +13,10 @@ module SorbetRails
13
13
  last(n)
14
14
  end
15
15
 
16
+ def select_columns(*args)
17
+ select(*args)
18
+ end
19
+
16
20
  # Redeclare these dynamic methods here otherwise they will be generated by
17
21
  # `srb rbi hidden-definitions`
18
22
  def find_by_id(id)
data/sorbet-rails.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{sorbet-rails}
3
- s.version = "0.7.5"
3
+ s.version = "0.7.#{ENV['GITHUB_RUN_NUMBER'] || 100}".strip
4
4
  s.date = %q{2019-04-18}
5
5
  s.summary = %q{Set of tools to make Sorbet work with Rails seamlessly.}
6
6
  s.authors = ["Chan Zuckerberg Initiative"]
@@ -84,6 +84,8 @@ T.assert_type!(Wizard.where.not(id: 1), Wizard::ActiveRecord_Relation)
84
84
  T.assert_type!(Wizard.preload(:spell_books), Wizard::ActiveRecord_Relation)
85
85
  T.assert_type!(Wizard.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
86
86
  T.assert_type!(Wizard.order(:id), Wizard::ActiveRecord_Relation)
87
+ T.assert_type!(Wizard.select { |r| r.id == 1 }, T::Array[Wizard])
88
+ T.assert_type!(Wizard.select_columns(:id, :name), Wizard::ActiveRecord_Relation)
87
89
 
88
90
  # Finder methods -- ActiveRecord::Relation
89
91
  T.assert_type!(Wizard.all.exists?(name: 'Harry Potter'), T::Boolean)
@@ -146,6 +148,8 @@ T.assert_type!(Wizard.all.where.not(id: 1), Wizard::ActiveRecord_Relation)
146
148
  T.assert_type!(Wizard.all.preload(:spell_books), Wizard::ActiveRecord_Relation)
147
149
  T.assert_type!(Wizard.all.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
148
150
  T.assert_type!(Wizard.all.order(:id), Wizard::ActiveRecord_Relation)
151
+ T.assert_type!(Wizard.all.select { |r| r.id == 1 }, T::Array[Wizard])
152
+ T.assert_type!(Wizard.all.select_columns(:id, :name), Wizard::ActiveRecord_Relation)
149
153
  # Enumerable methods
150
154
  Wizard.all.each { |w| T.assert_type!(w, Wizard) }
151
155
  Wizard.all.map { |w| T.assert_type!(w, Wizard) }
@@ -214,6 +218,9 @@ T.assert_type!(spell_books.where.not(id: 1), SpellBook::ActiveRecord_Association
214
218
  T.assert_type!(spell_books.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
215
219
  T.assert_type!(spell_books.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
216
220
  T.assert_type!(spell_books.order(:id), SpellBook::ActiveRecord_AssociationRelation)
221
+ T.assert_type!(spell_books.select { |r| r.id == 1 }, T::Array[SpellBook])
222
+ T.assert_type!(spell_books.select_columns(:id, :name), SpellBook::ActiveRecord_AssociationRelation)
223
+
217
224
  # Enumerable methods
218
225
  spell_books.each { |s| T.assert_type!(s, SpellBook) }
219
226
  spell_books.map { |s| T.assert_type!(s, SpellBook) }
@@ -290,6 +297,8 @@ T.assert_type!(spell_books_query.where.not(id: 1), SpellBook::ActiveRecord_Assoc
290
297
  T.assert_type!(spell_books_query.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
291
298
  T.assert_type!(spell_books_query.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
292
299
  T.assert_type!(spell_books_query.order(:id), SpellBook::ActiveRecord_AssociationRelation)
300
+ T.assert_type!(spell_books.select { |r| r.id == 1 }, T::Array[SpellBook])
301
+ T.assert_type!(spell_books.select_columns(:id, :name), SpellBook::ActiveRecord_AssociationRelation)
293
302
  # Enumerable methods
294
303
  spell_books_query.each { |s| T.assert_type!(s, SpellBook) }
295
304
  spell_books_query.map { |s| T.assert_type!(s, SpellBook) }
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../..
3
3
  specs:
4
- sorbet-rails (0.7.5)
4
+ sorbet-rails (0.7.100)
5
5
  method_source (>= 0.9.2)
6
6
  parlour (>= 4.0.1)
7
7
  parser (>= 2.7)
@@ -84,6 +84,8 @@ T.assert_type!(Wizard.where.not(id: 1), Wizard::ActiveRecord_Relation)
84
84
  T.assert_type!(Wizard.preload(:spell_books), Wizard::ActiveRecord_Relation)
85
85
  T.assert_type!(Wizard.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
86
86
  T.assert_type!(Wizard.order(:id), Wizard::ActiveRecord_Relation)
87
+ T.assert_type!(Wizard.select { |r| r.id == 1 }, T::Array[Wizard])
88
+ T.assert_type!(Wizard.select_columns(:id, :name), Wizard::ActiveRecord_Relation)
87
89
 
88
90
  # Finder methods -- ActiveRecord::Relation
89
91
  T.assert_type!(Wizard.all.exists?(name: 'Harry Potter'), T::Boolean)
@@ -146,6 +148,8 @@ T.assert_type!(Wizard.all.where.not(id: 1), Wizard::ActiveRecord_Relation)
146
148
  T.assert_type!(Wizard.all.preload(:spell_books), Wizard::ActiveRecord_Relation)
147
149
  T.assert_type!(Wizard.all.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
148
150
  T.assert_type!(Wizard.all.order(:id), Wizard::ActiveRecord_Relation)
151
+ T.assert_type!(Wizard.all.select { |r| r.id == 1 }, T::Array[Wizard])
152
+ T.assert_type!(Wizard.all.select_columns(:id, :name), Wizard::ActiveRecord_Relation)
149
153
  # Enumerable methods
150
154
  Wizard.all.each { |w| T.assert_type!(w, Wizard) }
151
155
  Wizard.all.map { |w| T.assert_type!(w, Wizard) }
@@ -214,6 +218,9 @@ T.assert_type!(spell_books.where.not(id: 1), SpellBook::ActiveRecord_Association
214
218
  T.assert_type!(spell_books.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
215
219
  T.assert_type!(spell_books.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
216
220
  T.assert_type!(spell_books.order(:id), SpellBook::ActiveRecord_AssociationRelation)
221
+ T.assert_type!(spell_books.select { |r| r.id == 1 }, T::Array[SpellBook])
222
+ T.assert_type!(spell_books.select_columns(:id, :name), SpellBook::ActiveRecord_AssociationRelation)
223
+
217
224
  # Enumerable methods
218
225
  spell_books.each { |s| T.assert_type!(s, SpellBook) }
219
226
  spell_books.map { |s| T.assert_type!(s, SpellBook) }
@@ -290,6 +297,8 @@ T.assert_type!(spell_books_query.where.not(id: 1), SpellBook::ActiveRecord_Assoc
290
297
  T.assert_type!(spell_books_query.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
291
298
  T.assert_type!(spell_books_query.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
292
299
  T.assert_type!(spell_books_query.order(:id), SpellBook::ActiveRecord_AssociationRelation)
300
+ T.assert_type!(spell_books.select { |r| r.id == 1 }, T::Array[SpellBook])
301
+ T.assert_type!(spell_books.select_columns(:id, :name), SpellBook::ActiveRecord_AssociationRelation)
293
302
  # Enumerable methods
294
303
  spell_books_query.each { |s| T.assert_type!(s, SpellBook) }
295
304
  spell_books_query.map { |s| T.assert_type!(s, SpellBook) }
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../..
3
3
  specs:
4
- sorbet-rails (0.7.5)
4
+ sorbet-rails (0.7.100)
5
5
  method_source (>= 0.9.2)
6
6
  parlour (>= 4.0.1)
7
7
  parser (>= 2.7)
@@ -84,6 +84,8 @@ T.assert_type!(Wizard.where.not(id: 1), Wizard::ActiveRecord_Relation)
84
84
  T.assert_type!(Wizard.preload(:spell_books), Wizard::ActiveRecord_Relation)
85
85
  T.assert_type!(Wizard.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
86
86
  T.assert_type!(Wizard.order(:id), Wizard::ActiveRecord_Relation)
87
+ T.assert_type!(Wizard.select { |r| r.id == 1 }, T::Array[Wizard])
88
+ T.assert_type!(Wizard.select_columns(:id, :name), Wizard::ActiveRecord_Relation)
87
89
 
88
90
  # Finder methods -- ActiveRecord::Relation
89
91
  T.assert_type!(Wizard.all.exists?(name: 'Harry Potter'), T::Boolean)
@@ -146,6 +148,8 @@ T.assert_type!(Wizard.all.where.not(id: 1), Wizard::ActiveRecord_Relation)
146
148
  T.assert_type!(Wizard.all.preload(:spell_books), Wizard::ActiveRecord_Relation)
147
149
  T.assert_type!(Wizard.all.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
148
150
  T.assert_type!(Wizard.all.order(:id), Wizard::ActiveRecord_Relation)
151
+ T.assert_type!(Wizard.all.select { |r| r.id == 1 }, T::Array[Wizard])
152
+ T.assert_type!(Wizard.all.select_columns(:id, :name), Wizard::ActiveRecord_Relation)
149
153
  # Enumerable methods
150
154
  Wizard.all.each { |w| T.assert_type!(w, Wizard) }
151
155
  Wizard.all.map { |w| T.assert_type!(w, Wizard) }
@@ -214,6 +218,9 @@ T.assert_type!(spell_books.where.not(id: 1), SpellBook::ActiveRecord_Association
214
218
  T.assert_type!(spell_books.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
215
219
  T.assert_type!(spell_books.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
216
220
  T.assert_type!(spell_books.order(:id), SpellBook::ActiveRecord_AssociationRelation)
221
+ T.assert_type!(spell_books.select { |r| r.id == 1 }, T::Array[SpellBook])
222
+ T.assert_type!(spell_books.select_columns(:id, :name), SpellBook::ActiveRecord_AssociationRelation)
223
+
217
224
  # Enumerable methods
218
225
  spell_books.each { |s| T.assert_type!(s, SpellBook) }
219
226
  spell_books.map { |s| T.assert_type!(s, SpellBook) }
@@ -290,6 +297,8 @@ T.assert_type!(spell_books_query.where.not(id: 1), SpellBook::ActiveRecord_Assoc
290
297
  T.assert_type!(spell_books_query.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
291
298
  T.assert_type!(spell_books_query.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
292
299
  T.assert_type!(spell_books_query.order(:id), SpellBook::ActiveRecord_AssociationRelation)
300
+ T.assert_type!(spell_books.select { |r| r.id == 1 }, T::Array[SpellBook])
301
+ T.assert_type!(spell_books.select_columns(:id, :name), SpellBook::ActiveRecord_AssociationRelation)
293
302
  # Enumerable methods
294
303
  spell_books_query.each { |s| T.assert_type!(s, SpellBook) }
295
304
  spell_books_query.map { |s| T.assert_type!(s, SpellBook) }
@@ -84,6 +84,8 @@ T.assert_type!(Wizard.where.not(id: 1), Wizard::ActiveRecord_Relation)
84
84
  T.assert_type!(Wizard.preload(:spell_books), Wizard::ActiveRecord_Relation)
85
85
  T.assert_type!(Wizard.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
86
86
  T.assert_type!(Wizard.order(:id), Wizard::ActiveRecord_Relation)
87
+ T.assert_type!(Wizard.select { |r| r.id == 1 }, T::Array[Wizard])
88
+ T.assert_type!(Wizard.select_columns(:id, :name), Wizard::ActiveRecord_Relation)
87
89
 
88
90
  # Finder methods -- ActiveRecord::Relation
89
91
  T.assert_type!(Wizard.all.exists?(name: 'Harry Potter'), T::Boolean)
@@ -146,6 +148,8 @@ T.assert_type!(Wizard.all.where.not(id: 1), Wizard::ActiveRecord_Relation)
146
148
  T.assert_type!(Wizard.all.preload(:spell_books), Wizard::ActiveRecord_Relation)
147
149
  T.assert_type!(Wizard.all.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
148
150
  T.assert_type!(Wizard.all.order(:id), Wizard::ActiveRecord_Relation)
151
+ T.assert_type!(Wizard.all.select { |r| r.id == 1 }, T::Array[Wizard])
152
+ T.assert_type!(Wizard.all.select_columns(:id, :name), Wizard::ActiveRecord_Relation)
149
153
  # Enumerable methods
150
154
  Wizard.all.each { |w| T.assert_type!(w, Wizard) }
151
155
  Wizard.all.map { |w| T.assert_type!(w, Wizard) }
@@ -214,6 +218,9 @@ T.assert_type!(spell_books.where.not(id: 1), SpellBook::ActiveRecord_Association
214
218
  T.assert_type!(spell_books.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
215
219
  T.assert_type!(spell_books.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
216
220
  T.assert_type!(spell_books.order(:id), SpellBook::ActiveRecord_AssociationRelation)
221
+ T.assert_type!(spell_books.select { |r| r.id == 1 }, T::Array[SpellBook])
222
+ T.assert_type!(spell_books.select_columns(:id, :name), SpellBook::ActiveRecord_AssociationRelation)
223
+
217
224
  # Enumerable methods
218
225
  spell_books.each { |s| T.assert_type!(s, SpellBook) }
219
226
  spell_books.map { |s| T.assert_type!(s, SpellBook) }
@@ -290,6 +297,8 @@ T.assert_type!(spell_books_query.where.not(id: 1), SpellBook::ActiveRecord_Assoc
290
297
  T.assert_type!(spell_books_query.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
291
298
  T.assert_type!(spell_books_query.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
292
299
  T.assert_type!(spell_books_query.order(:id), SpellBook::ActiveRecord_AssociationRelation)
300
+ T.assert_type!(spell_books.select { |r| r.id == 1 }, T::Array[SpellBook])
301
+ T.assert_type!(spell_books.select_columns(:id, :name), SpellBook::ActiveRecord_AssociationRelation)
293
302
  # Enumerable methods
294
303
  spell_books_query.each { |s| T.assert_type!(s, SpellBook) }
295
304
  spell_books_query.map { |s| T.assert_type!(s, SpellBook) }
@@ -76,9 +76,6 @@ module ActiveStorage::Attachment::QueryMethodsReturningRelation
76
76
  sig { params(block: T.nilable(T.proc.void)).returns(ActiveStorage::Attachment::ActiveRecord_Relation) }
77
77
  def unscoped(&block); end
78
78
 
79
- sig { params(args: T.untyped).returns(ActiveStorage::Attachment::ActiveRecord_Relation) }
80
- def select(*args); end
81
-
82
79
  sig { params(args: T.untyped).returns(ActiveStorage::Attachment::ActiveRecord_Relation) }
83
80
  def order(*args); end
84
81
 
@@ -154,6 +151,12 @@ module ActiveStorage::Attachment::QueryMethodsReturningRelation
154
151
  sig { params(args: T.untyped).returns(ActiveStorage::Attachment::ActiveRecord_Relation) }
155
152
  def except(*args); end
156
153
 
154
+ sig { params(block: T.proc.params(e: ActiveStorage::Attachment).returns(T::Boolean)).returns(T::Array[ActiveStorage::Attachment]) }
155
+ def select(&block); end
156
+
157
+ sig { params(args: T.any(String, Symbol)).returns(ActiveStorage::Attachment::ActiveRecord_Relation) }
158
+ def select_columns(*args); end
159
+
157
160
  sig { params(args: T.untyped, block: T.nilable(T.proc.void)).returns(ActiveStorage::Attachment::ActiveRecord_Relation) }
158
161
  def extending(*args, &block); end
159
162
 
@@ -177,9 +180,6 @@ module ActiveStorage::Attachment::QueryMethodsReturningAssociationRelation
177
180
  sig { params(block: T.nilable(T.proc.void)).returns(ActiveStorage::Attachment::ActiveRecord_Relation) }
178
181
  def unscoped(&block); end
179
182
 
180
- sig { params(args: T.untyped).returns(ActiveStorage::Attachment::ActiveRecord_AssociationRelation) }
181
- def select(*args); end
182
-
183
183
  sig { params(args: T.untyped).returns(ActiveStorage::Attachment::ActiveRecord_AssociationRelation) }
184
184
  def order(*args); end
185
185
 
@@ -255,6 +255,12 @@ module ActiveStorage::Attachment::QueryMethodsReturningAssociationRelation
255
255
  sig { params(args: T.untyped).returns(ActiveStorage::Attachment::ActiveRecord_AssociationRelation) }
256
256
  def except(*args); end
257
257
 
258
+ sig { params(block: T.proc.params(e: ActiveStorage::Attachment).returns(T::Boolean)).returns(T::Array[ActiveStorage::Attachment]) }
259
+ def select(&block); end
260
+
261
+ sig { params(args: T.any(String, Symbol)).returns(ActiveStorage::Attachment::ActiveRecord_AssociationRelation) }
262
+ def select_columns(*args); end
263
+
258
264
  sig { params(args: T.untyped, block: T.nilable(T.proc.void)).returns(ActiveStorage::Attachment::ActiveRecord_AssociationRelation) }
259
265
  def extending(*args, &block); end
260
266
 
@@ -141,9 +141,6 @@ module ActiveStorage::Blob::QueryMethodsReturningRelation
141
141
  sig { params(block: T.nilable(T.proc.void)).returns(ActiveStorage::Blob::ActiveRecord_Relation) }
142
142
  def unscoped(&block); end
143
143
 
144
- sig { params(args: T.untyped).returns(ActiveStorage::Blob::ActiveRecord_Relation) }
145
- def select(*args); end
146
-
147
144
  sig { params(args: T.untyped).returns(ActiveStorage::Blob::ActiveRecord_Relation) }
148
145
  def order(*args); end
149
146
 
@@ -219,6 +216,12 @@ module ActiveStorage::Blob::QueryMethodsReturningRelation
219
216
  sig { params(args: T.untyped).returns(ActiveStorage::Blob::ActiveRecord_Relation) }
220
217
  def except(*args); end
221
218
 
219
+ sig { params(block: T.proc.params(e: ActiveStorage::Blob).returns(T::Boolean)).returns(T::Array[ActiveStorage::Blob]) }
220
+ def select(&block); end
221
+
222
+ sig { params(args: T.any(String, Symbol)).returns(ActiveStorage::Blob::ActiveRecord_Relation) }
223
+ def select_columns(*args); end
224
+
222
225
  sig { params(args: T.untyped, block: T.nilable(T.proc.void)).returns(ActiveStorage::Blob::ActiveRecord_Relation) }
223
226
  def extending(*args, &block); end
224
227
 
@@ -242,9 +245,6 @@ module ActiveStorage::Blob::QueryMethodsReturningAssociationRelation
242
245
  sig { params(block: T.nilable(T.proc.void)).returns(ActiveStorage::Blob::ActiveRecord_Relation) }
243
246
  def unscoped(&block); end
244
247
 
245
- sig { params(args: T.untyped).returns(ActiveStorage::Blob::ActiveRecord_AssociationRelation) }
246
- def select(*args); end
247
-
248
248
  sig { params(args: T.untyped).returns(ActiveStorage::Blob::ActiveRecord_AssociationRelation) }
249
249
  def order(*args); end
250
250
 
@@ -320,6 +320,12 @@ module ActiveStorage::Blob::QueryMethodsReturningAssociationRelation
320
320
  sig { params(args: T.untyped).returns(ActiveStorage::Blob::ActiveRecord_AssociationRelation) }
321
321
  def except(*args); end
322
322
 
323
+ sig { params(block: T.proc.params(e: ActiveStorage::Blob).returns(T::Boolean)).returns(T::Array[ActiveStorage::Blob]) }
324
+ def select(&block); end
325
+
326
+ sig { params(args: T.any(String, Symbol)).returns(ActiveStorage::Blob::ActiveRecord_AssociationRelation) }
327
+ def select_columns(*args); end
328
+
323
329
  sig { params(args: T.untyped, block: T.nilable(T.proc.void)).returns(ActiveStorage::Blob::ActiveRecord_AssociationRelation) }
324
330
  def extending(*args, &block); end
325
331
 
@@ -106,9 +106,6 @@ module Headmaster::QueryMethodsReturningRelation
106
106
  sig { params(block: T.nilable(T.proc.void)).returns(Headmaster::ActiveRecord_Relation) }
107
107
  def unscoped(&block); end
108
108
 
109
- sig { params(args: T.untyped).returns(Headmaster::ActiveRecord_Relation) }
110
- def select(*args); end
111
-
112
109
  sig { params(args: T.untyped).returns(Headmaster::ActiveRecord_Relation) }
113
110
  def order(*args); end
114
111
 
@@ -184,6 +181,12 @@ module Headmaster::QueryMethodsReturningRelation
184
181
  sig { params(args: T.untyped).returns(Headmaster::ActiveRecord_Relation) }
185
182
  def except(*args); end
186
183
 
184
+ sig { params(block: T.proc.params(e: Headmaster).returns(T::Boolean)).returns(T::Array[Headmaster]) }
185
+ def select(&block); end
186
+
187
+ sig { params(args: T.any(String, Symbol)).returns(Headmaster::ActiveRecord_Relation) }
188
+ def select_columns(*args); end
189
+
187
190
  sig { params(args: T.untyped, block: T.nilable(T.proc.void)).returns(Headmaster::ActiveRecord_Relation) }
188
191
  def extending(*args, &block); end
189
192
 
@@ -207,9 +210,6 @@ module Headmaster::QueryMethodsReturningAssociationRelation
207
210
  sig { params(block: T.nilable(T.proc.void)).returns(Headmaster::ActiveRecord_Relation) }
208
211
  def unscoped(&block); end
209
212
 
210
- sig { params(args: T.untyped).returns(Headmaster::ActiveRecord_AssociationRelation) }
211
- def select(*args); end
212
-
213
213
  sig { params(args: T.untyped).returns(Headmaster::ActiveRecord_AssociationRelation) }
214
214
  def order(*args); end
215
215
 
@@ -285,6 +285,12 @@ module Headmaster::QueryMethodsReturningAssociationRelation
285
285
  sig { params(args: T.untyped).returns(Headmaster::ActiveRecord_AssociationRelation) }
286
286
  def except(*args); end
287
287
 
288
+ sig { params(block: T.proc.params(e: Headmaster).returns(T::Boolean)).returns(T::Array[Headmaster]) }
289
+ def select(&block); end
290
+
291
+ sig { params(args: T.any(String, Symbol)).returns(Headmaster::ActiveRecord_AssociationRelation) }
292
+ def select_columns(*args); end
293
+
288
294
  sig { params(args: T.untyped, block: T.nilable(T.proc.void)).returns(Headmaster::ActiveRecord_AssociationRelation) }
289
295
  def extending(*args, &block); end
290
296
 
@@ -76,9 +76,6 @@ module ActiveRecord::InternalMetadata::QueryMethodsReturningRelation
76
76
  sig { params(block: T.nilable(T.proc.void)).returns(ActiveRecord::InternalMetadata::ActiveRecord_Relation) }
77
77
  def unscoped(&block); end
78
78
 
79
- sig { params(args: T.untyped).returns(ActiveRecord::InternalMetadata::ActiveRecord_Relation) }
80
- def select(*args); end
81
-
82
79
  sig { params(args: T.untyped).returns(ActiveRecord::InternalMetadata::ActiveRecord_Relation) }
83
80
  def order(*args); end
84
81
 
@@ -154,6 +151,12 @@ module ActiveRecord::InternalMetadata::QueryMethodsReturningRelation
154
151
  sig { params(args: T.untyped).returns(ActiveRecord::InternalMetadata::ActiveRecord_Relation) }
155
152
  def except(*args); end
156
153
 
154
+ sig { params(block: T.proc.params(e: ActiveRecord::InternalMetadata).returns(T::Boolean)).returns(T::Array[ActiveRecord::InternalMetadata]) }
155
+ def select(&block); end
156
+
157
+ sig { params(args: T.any(String, Symbol)).returns(ActiveRecord::InternalMetadata::ActiveRecord_Relation) }
158
+ def select_columns(*args); end
159
+
157
160
  sig { params(args: T.untyped, block: T.nilable(T.proc.void)).returns(ActiveRecord::InternalMetadata::ActiveRecord_Relation) }
158
161
  def extending(*args, &block); end
159
162
 
@@ -177,9 +180,6 @@ module ActiveRecord::InternalMetadata::QueryMethodsReturningAssociationRelation
177
180
  sig { params(block: T.nilable(T.proc.void)).returns(ActiveRecord::InternalMetadata::ActiveRecord_Relation) }
178
181
  def unscoped(&block); end
179
182
 
180
- sig { params(args: T.untyped).returns(ActiveRecord::InternalMetadata::ActiveRecord_AssociationRelation) }
181
- def select(*args); end
182
-
183
183
  sig { params(args: T.untyped).returns(ActiveRecord::InternalMetadata::ActiveRecord_AssociationRelation) }
184
184
  def order(*args); end
185
185
 
@@ -255,6 +255,12 @@ module ActiveRecord::InternalMetadata::QueryMethodsReturningAssociationRelation
255
255
  sig { params(args: T.untyped).returns(ActiveRecord::InternalMetadata::ActiveRecord_AssociationRelation) }
256
256
  def except(*args); end
257
257
 
258
+ sig { params(block: T.proc.params(e: ActiveRecord::InternalMetadata).returns(T::Boolean)).returns(T::Array[ActiveRecord::InternalMetadata]) }
259
+ def select(&block); end
260
+
261
+ sig { params(args: T.any(String, Symbol)).returns(ActiveRecord::InternalMetadata::ActiveRecord_AssociationRelation) }
262
+ def select_columns(*args); end
263
+
258
264
  sig { params(args: T.untyped, block: T.nilable(T.proc.void)).returns(ActiveRecord::InternalMetadata::ActiveRecord_AssociationRelation) }
259
265
  def extending(*args, &block); end
260
266
 
@@ -58,9 +58,6 @@ module Potion::QueryMethodsReturningRelation
58
58
  sig { params(block: T.nilable(T.proc.void)).returns(Potion::ActiveRecord_Relation) }
59
59
  def unscoped(&block); end
60
60
 
61
- sig { params(args: T.untyped).returns(Potion::ActiveRecord_Relation) }
62
- def select(*args); end
63
-
64
61
  sig { params(args: T.untyped).returns(Potion::ActiveRecord_Relation) }
65
62
  def order(*args); end
66
63
 
@@ -136,6 +133,12 @@ module Potion::QueryMethodsReturningRelation
136
133
  sig { params(args: T.untyped).returns(Potion::ActiveRecord_Relation) }
137
134
  def except(*args); end
138
135
 
136
+ sig { params(block: T.proc.params(e: Potion).returns(T::Boolean)).returns(T::Array[Potion]) }
137
+ def select(&block); end
138
+
139
+ sig { params(args: T.any(String, Symbol)).returns(Potion::ActiveRecord_Relation) }
140
+ def select_columns(*args); end
141
+
139
142
  sig { params(args: T.untyped, block: T.nilable(T.proc.void)).returns(Potion::ActiveRecord_Relation) }
140
143
  def extending(*args, &block); end
141
144
 
@@ -159,9 +162,6 @@ module Potion::QueryMethodsReturningAssociationRelation
159
162
  sig { params(block: T.nilable(T.proc.void)).returns(Potion::ActiveRecord_Relation) }
160
163
  def unscoped(&block); end
161
164
 
162
- sig { params(args: T.untyped).returns(Potion::ActiveRecord_AssociationRelation) }
163
- def select(*args); end
164
-
165
165
  sig { params(args: T.untyped).returns(Potion::ActiveRecord_AssociationRelation) }
166
166
  def order(*args); end
167
167
 
@@ -237,6 +237,12 @@ module Potion::QueryMethodsReturningAssociationRelation
237
237
  sig { params(args: T.untyped).returns(Potion::ActiveRecord_AssociationRelation) }
238
238
  def except(*args); end
239
239
 
240
+ sig { params(block: T.proc.params(e: Potion).returns(T::Boolean)).returns(T::Array[Potion]) }
241
+ def select(&block); end
242
+
243
+ sig { params(args: T.any(String, Symbol)).returns(Potion::ActiveRecord_AssociationRelation) }
244
+ def select_columns(*args); end
245
+
240
246
  sig { params(args: T.untyped, block: T.nilable(T.proc.void)).returns(Potion::ActiveRecord_AssociationRelation) }
241
247
  def extending(*args, &block); end
242
248
 
@@ -79,9 +79,6 @@ module Robe::QueryMethodsReturningRelation
79
79
  sig { params(block: T.nilable(T.proc.void)).returns(Robe::ActiveRecord_Relation) }
80
80
  def unscoped(&block); end
81
81
 
82
- sig { params(args: T.untyped).returns(Robe::ActiveRecord_Relation) }
83
- def select(*args); end
84
-
85
82
  sig { params(args: T.untyped).returns(Robe::ActiveRecord_Relation) }
86
83
  def order(*args); end
87
84
 
@@ -157,6 +154,12 @@ module Robe::QueryMethodsReturningRelation
157
154
  sig { params(args: T.untyped).returns(Robe::ActiveRecord_Relation) }
158
155
  def except(*args); end
159
156
 
157
+ sig { params(block: T.proc.params(e: Robe).returns(T::Boolean)).returns(T::Array[Robe]) }
158
+ def select(&block); end
159
+
160
+ sig { params(args: T.any(String, Symbol)).returns(Robe::ActiveRecord_Relation) }
161
+ def select_columns(*args); end
162
+
160
163
  sig { params(args: T.untyped, block: T.nilable(T.proc.void)).returns(Robe::ActiveRecord_Relation) }
161
164
  def extending(*args, &block); end
162
165
 
@@ -180,9 +183,6 @@ module Robe::QueryMethodsReturningAssociationRelation
180
183
  sig { params(block: T.nilable(T.proc.void)).returns(Robe::ActiveRecord_Relation) }
181
184
  def unscoped(&block); end
182
185
 
183
- sig { params(args: T.untyped).returns(Robe::ActiveRecord_AssociationRelation) }
184
- def select(*args); end
185
-
186
186
  sig { params(args: T.untyped).returns(Robe::ActiveRecord_AssociationRelation) }
187
187
  def order(*args); end
188
188
 
@@ -258,6 +258,12 @@ module Robe::QueryMethodsReturningAssociationRelation
258
258
  sig { params(args: T.untyped).returns(Robe::ActiveRecord_AssociationRelation) }
259
259
  def except(*args); end
260
260
 
261
+ sig { params(block: T.proc.params(e: Robe).returns(T::Boolean)).returns(T::Array[Robe]) }
262
+ def select(&block); end
263
+
264
+ sig { params(args: T.any(String, Symbol)).returns(Robe::ActiveRecord_AssociationRelation) }
265
+ def select_columns(*args); end
266
+
261
267
  sig { params(args: T.untyped, block: T.nilable(T.proc.void)).returns(Robe::ActiveRecord_AssociationRelation) }
262
268
  def extending(*args, &block); end
263
269