-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add: ActiveRecord::QueryMethods::WhereChain#missing #596
add: ActiveRecord::QueryMethods::WhereChain#missing #596
Conversation
31bd3e6
to
6b26687
Compare
@rhiroe Thanks for your contribution! Please follow the instructions below for each change. Available commandsYou can use the following commands by commenting on this PR.
|
6b26687
to
f34ee44
Compare
Added `ActiveRecord::QueryMethods::WhereChain#missing` in version 6.1 or later. Fixed to return `::ActiveRecord::QueryMethods::WhereChain` when the `where` method has no argument.
f34ee44
to
ccaa96f
Compare
@rhiroe Thanks for your contribution! Please follow the instructions below for each change. Available commandsYou can use the following commands by commenting on this PR.
|
|
||
module QueryMethods | ||
class WhereChain | ||
def missing: (*Symbol associations) -> Relation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Relation
is ::ActiveRecord::Relation
.
So, the model information is missing.
Aren't you trying to get the model information from here?
How about like this?
module QueryMethods
class WhereChain[Relation]
def missing: (*Symbol associations) -> Relation
end
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost good 👍
Can you add testing code for missing
?
If we mimic the RBS generated by rbs-rails, we can write it like this... class User < ActiveRecord::Base
extend _ActiveRecord_Relation_ClassMethods[User, ActiveRecord_Relation, Integer]
class ActiveRecord_Relation < ::ActiveRecord::Relation
include _ActiveRecord_Relation[User, Integer]
include Enumerable[User]
end
class ActiveRecord_Associations_CollectionProxy < ::ActiveRecord::Associations::CollectionProxy
include _ActiveRecord_Relation[User, Integer]
end
end Include or extend
So I include or extend It looks like it was designed for that purpose. |
It is enough to show that |
@ksss Sorry, I have a question. |
Yes. It seems to me that there is an increase in excessively managed test code. The test code I had in mind is as follows: User.where.missing.to_sql |
I see. Thank you for your answer and example. |
c429445
to
0d03dd3
Compare
0d03dd3
to
02ffe1e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APPROVE
/merge |
Added
ActiveRecord::QueryMethods::WhereChain#missing
in version 6.1 or later.Fixed to return
::ActiveRecord::QueryMethods::WhereChain
when thewhere
method has no argument.I confirmed that no errors occurred when used with rbs-rails.