Skip to content
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

Generate correct return types in IdentityCache compiler #1939

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/tapioca/dsl/compilers/identity_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def create_aliased_fetch_by_methods(field, klass)
"fetch_#{suffix}",
class_method: true,
parameters: parameters,
return_type: type,
return_type: field.unique ? type : COLLECTION_TYPE.call(type),
)

klass.create_method(
Expand Down
10 changes: 5 additions & 5 deletions spec/tapioca/dsl/compilers/identity_cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ def fetch_by_blog_id(blog_id, includes: nil); end
sig { params(title: T.untyped, includes: T.untyped).returns(T::Array[::Post]) }
def fetch_by_title(title, includes: nil); end

sig { params(blog_id: T.untyped).returns(T.nilable(::Integer)) }
sig { params(blog_id: T.untyped).returns(T::Array[::T.nilable(::Integer)]) }
def fetch_id_by_blog_id(blog_id); end

sig { params(title: T.untyped).returns(T.nilable(::Integer)) }
sig { params(title: T.untyped).returns(T::Array[::T.nilable(::Integer)]) }
def fetch_id_by_title(title); end

sig { params(index_values: T::Enumerable[T.untyped], includes: T.untyped).returns(T::Array[::Post]) }
Expand Down Expand Up @@ -148,7 +148,7 @@ def fetch_by_title(title, includes: nil); end
sig { params(title: T.untyped, includes: T.untyped).returns(::Post) }
def fetch_by_title!(title, includes: nil); end

sig { params(blog_id: T.untyped).returns(T.nilable(::Integer)) }
sig { params(blog_id: T.untyped).returns(T::Array[::T.nilable(::Integer)]) }
def fetch_id_by_blog_id(blog_id); end

sig { params(title: T.untyped).returns(T.nilable(::Integer)) }
Expand Down Expand Up @@ -199,7 +199,7 @@ class << self
sig { params(blog_id: T.untyped, title: T.untyped, includes: T.untyped).returns(T::Array[::Post]) }
def fetch_by_blog_id_and_title(blog_id, title, includes: nil); end

sig { params(blog_id: T.untyped, title: T.untyped).returns(T.nilable(::Integer)) }
sig { params(blog_id: T.untyped, title: T.untyped).returns(T::Array[::T.nilable(::Integer)]) }
def fetch_id_by_blog_id_and_title(blog_id, title); end

sig { params(index_values: T::Enumerable[T.untyped], includes: T.untyped).returns(T::Array[::Post]) }
Expand Down Expand Up @@ -248,7 +248,7 @@ def fetch_by_title_and_review_date(title, review_date, includes: nil); end
sig { params(title: T.untyped, review_date: T.untyped, includes: T.untyped).returns(::Post) }
def fetch_by_title_and_review_date!(title, review_date, includes: nil); end

sig { params(title: T.untyped).returns(T.nilable(::Integer)) }
sig { params(title: T.untyped).returns(T::Array[::T.nilable(::Integer)]) }
def fetch_id_by_title(title); end

sig { params(title: T.untyped, review_date: T.untyped).returns(T.nilable(::Integer)) }
Expand Down
Loading