sorbet-rails 0.7.19 → 0.7.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +1 -1
  3. data/.github/workflows/publish-gem.yml +9 -0
  4. data/README.md +9 -1
  5. data/lib/sorbet-rails/model_plugins/active_record_querying.rb +25 -1
  6. data/lib/sorbet-rails/model_utils.rb +14 -7
  7. data/lib/sorbet-rails/rails_mixins/custom_finder_methods.rb +4 -0
  8. data/sorbet-rails.gemspec +1 -1
  9. data/spec/generators/sorbet_test_cases.rb +9 -0
  10. data/spec/support/v5.2/Gemfile.lock +1 -1
  11. data/spec/support/v5.2/sorbet_test_cases.rb +9 -0
  12. data/spec/support/v6.0/Gemfile.lock +1 -1
  13. data/spec/support/v6.0/sorbet_test_cases.rb +9 -0
  14. data/spec/support/v6.1/sorbet_test_cases.rb +9 -0
  15. data/spec/test_data/v5.2/expected_attachment.rbi +12 -6
  16. data/spec/test_data/v5.2/expected_blob.rbi +12 -6
  17. data/spec/test_data/v5.2/expected_headmaster.rbi +12 -6
  18. data/spec/test_data/v5.2/expected_internal_metadata.rbi +12 -6
  19. data/spec/test_data/v5.2/expected_potion.rbi +12 -6
  20. data/spec/test_data/v5.2/expected_robe.rbi +12 -6
  21. data/spec/test_data/v5.2/expected_schema_migration.rbi +12 -6
  22. data/spec/test_data/v5.2/expected_school.rbi +12 -6
  23. data/spec/test_data/v5.2/expected_spell/habtm_spell_books.rbi +12 -6
  24. data/spec/test_data/v5.2/expected_spell.rbi +12 -6
  25. data/spec/test_data/v5.2/expected_spell_book/habtm_spells.rbi +12 -6
  26. data/spec/test_data/v5.2/expected_spell_book.rbi +12 -6
  27. data/spec/test_data/v5.2/expected_squib.rbi +12 -6
  28. data/spec/test_data/v5.2/expected_subject/habtm_wizards.rbi +12 -6
  29. data/spec/test_data/v5.2/expected_subject.rbi +12 -6
  30. data/spec/test_data/v5.2/expected_wand.rbi +12 -6
  31. data/spec/test_data/v5.2/expected_wizard/habtm_subjects.rbi +12 -6
  32. data/spec/test_data/v5.2/expected_wizard.rbi +12 -6
  33. data/spec/test_data/v5.2/expected_wizard_wo_spellbook.rbi +12 -6
  34. data/spec/test_data/v6.0/expected_attachment.rbi +12 -6
  35. data/spec/test_data/v6.0/expected_blob.rbi +12 -6
  36. data/spec/test_data/v6.0/expected_headmaster.rbi +12 -6
  37. data/spec/test_data/v6.0/expected_internal_metadata.rbi +12 -6
  38. data/spec/test_data/v6.0/expected_potion.rbi +12 -6
  39. data/spec/test_data/v6.0/expected_robe.rbi +12 -6
  40. data/spec/test_data/v6.0/expected_schema_migration.rbi +12 -6
  41. data/spec/test_data/v6.0/expected_school.rbi +12 -6
  42. data/spec/test_data/v6.0/expected_spell/habtm_spell_books.rbi +12 -6
  43. data/spec/test_data/v6.0/expected_spell.rbi +12 -6
  44. data/spec/test_data/v6.0/expected_spell_book/habtm_spells.rbi +12 -6
  45. data/spec/test_data/v6.0/expected_spell_book.rbi +12 -6
  46. data/spec/test_data/v6.0/expected_squib.rbi +12 -6
  47. data/spec/test_data/v6.0/expected_subject/habtm_wizards.rbi +12 -6
  48. data/spec/test_data/v6.0/expected_subject.rbi +12 -6
  49. data/spec/test_data/v6.0/expected_wand.rbi +12 -6
  50. data/spec/test_data/v6.0/expected_wizard/habtm_subjects.rbi +12 -6
  51. data/spec/test_data/v6.0/expected_wizard.rbi +12 -6
  52. data/spec/test_data/v6.0/expected_wizard_wo_spellbook.rbi +12 -6
  53. data/spec/test_data/v6.1/expected_attachment.rbi +12 -6
  54. data/spec/test_data/v6.1/expected_blob.rbi +12 -6
  55. data/spec/test_data/v6.1/expected_headmaster.rbi +12 -6
  56. data/spec/test_data/v6.1/expected_internal_metadata.rbi +12 -6
  57. data/spec/test_data/v6.1/expected_potion.rbi +12 -6
  58. data/spec/test_data/v6.1/expected_record.rbi +12 -6
  59. data/spec/test_data/v6.1/expected_robe.rbi +12 -6
  60. data/spec/test_data/v6.1/expected_schema_migration.rbi +12 -6
  61. data/spec/test_data/v6.1/expected_school.rbi +12 -6
  62. data/spec/test_data/v6.1/expected_spell/habtm_spell_books.rbi +12 -6
  63. data/spec/test_data/v6.1/expected_spell.rbi +12 -6
  64. data/spec/test_data/v6.1/expected_spell_book/habtm_spells.rbi +12 -6
  65. data/spec/test_data/v6.1/expected_spell_book.rbi +12 -6
  66. data/spec/test_data/v6.1/expected_squib.rbi +12 -6
  67. data/spec/test_data/v6.1/expected_subject/habtm_wizards.rbi +12 -6
  68. data/spec/test_data/v6.1/expected_subject.rbi +12 -6
  69. data/spec/test_data/v6.1/expected_variant_record.rbi +12 -6
  70. data/spec/test_data/v6.1/expected_wand.rbi +12 -6
  71. data/spec/test_data/v6.1/expected_wizard/habtm_subjects.rbi +12 -6
  72. data/spec/test_data/v6.1/expected_wizard.rbi +12 -6
  73. data/spec/test_data/v6.1/expected_wizard_wo_spellbook.rbi +12 -6
  74. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46916b2838ddb2a8dbbbc8e7ddbaa6a01daa7c7d6be081cb26661ac23f314ffc
4
- data.tar.gz: 9dbc6e5beedbf770274f2a0ef21a422579f80d1c27d14dea882109167e05acc7
3
+ metadata.gz: ea9995d332dc919678919021f657e1b0e6c97030b951c046ec3c5679d67259ef
4
+ data.tar.gz: 4ee98435162b3514c091e0e4f2e716b90a350f5b9ec5e4c01aa2237e3df62c21
5
5
  SHA512:
6
- metadata.gz: 44e3a47dd6a57252cb1df2db05fd7c7717e9409e8739f9e8e9040092a3f1400390ed9de1cfd142f7efa79272718c1726ea73948787d458e8b3b7daf581d6de5c
7
- data.tar.gz: ef8f746a76f3cda2bf5e83a0e94c6927487ce45d8ca3e8adc2cba42c0811d06ffeef44f6a6c09806ca659381c4c4b4f0adcde01c42f4375a45700331a1dde66e
6
+ metadata.gz: '009ecc5a48c03bdf2169355907c43c92baaf570eaed5b8770d4afe8fe2bff377c4204a78dc4ed27a151854606bba464152f74ac3ed49a640ee55ae9e37afeebf'
7
+ data.tar.gz: c317f146ba948570d989aad38f9d11e1fff5dcae666284513f574be1630177c6be668f341731244b4b6803b0a154cba6d45c23c6c4f2194190c632c54a534a1b
@@ -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
@@ -10,8 +10,17 @@ jobs:
10
10
  build:
11
11
  runs-on: ubuntu-latest
12
12
 
13
+ env:
14
+ RAILS_VERSION: 6.0
15
+
13
16
  steps:
14
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
15
24
  - name: Release Gem
16
25
  uses: dawidd6/action-publish-gem@v1
17
26
  with:
data/README.md CHANGED
@@ -411,8 +411,16 @@ Model.unscoped.scoping do … end
411
411
 
412
412
  ### `select` with a block
413
413
 
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. 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
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.
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
+ ```
416
424
  ### `flatten` an array of relation
417
425
 
418
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, T::Array[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.#{ENV['GITHUB_RUN_NUMBER']}".strip
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, T::Array[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, T::Array[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, T::Array[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, T::Array[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, T::Array[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, T::Array[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, T::Array[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, T::Array[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, T::Array[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, T::Array[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, T::Array[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, T::Array[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