Skip to content

Commit

Permalink
Merge pull request #1882 from bdewater/ar-distinct
Browse files Browse the repository at this point in the history
Improve ActiveRecord::QueryMethods#distinct
  • Loading branch information
egiurleo committed Apr 23, 2024
2 parents 7533e71 + 8b08af1 commit 2df42eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions lib/tapioca/dsl/compilers/active_record_relations.rb
Expand Up @@ -561,6 +561,11 @@ def create_relation_methods

QUERY_METHODS.each do |method_name|
case method_name
when :distinct
create_relation_method(
method_name.to_s,
parameters: [create_opt_param("value", type: "T::Boolean", default: "true")],
)
when :extract_associated
parameters = [create_param("association", type: "Symbol")]
return_type = "T::Array[T.untyped]"
Expand Down
16 changes: 8 additions & 8 deletions spec/tapioca/dsl/compilers/active_record_relations_spec.rb
Expand Up @@ -268,8 +268,8 @@ def annotate(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(PrivateAssociationRelation) }
def create_with(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(PrivateAssociationRelation) }
def distinct(*args, &blk); end
sig { params(value: T::Boolean).returns(PrivateAssociationRelation) }
def distinct(value = true); end
sig { params(args: T.untyped, blk: T.untyped).returns(PrivateAssociationRelation) }
def eager_load(*args, &blk); end
Expand Down Expand Up @@ -439,8 +439,8 @@ def annotate(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(PrivateRelation) }
def create_with(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(PrivateRelation) }
def distinct(*args, &blk); end
sig { params(value: T::Boolean).returns(PrivateRelation) }
def distinct(value = true); end
sig { params(args: T.untyped, blk: T.untyped).returns(PrivateRelation) }
def eager_load(*args, &blk); end
Expand Down Expand Up @@ -965,8 +965,8 @@ def annotate(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(PrivateAssociationRelation) }
def create_with(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(PrivateAssociationRelation) }
def distinct(*args, &blk); end
sig { params(value: T::Boolean).returns(PrivateAssociationRelation) }
def distinct(value = true); end
sig { params(args: T.untyped, blk: T.untyped).returns(PrivateAssociationRelation) }
def eager_load(*args, &blk); end
Expand Down Expand Up @@ -1136,8 +1136,8 @@ def annotate(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(PrivateRelation) }
def create_with(*args, &blk); end
sig { params(args: T.untyped, blk: T.untyped).returns(PrivateRelation) }
def distinct(*args, &blk); end
sig { params(value: T::Boolean).returns(PrivateRelation) }
def distinct(value = true); end
sig { params(args: T.untyped, blk: T.untyped).returns(PrivateRelation) }
def eager_load(*args, &blk); end
Expand Down

0 comments on commit 2df42eb

Please sign in to comment.