diff --git a/lib/tapioca/dsl/compilers/identity_cache.rb b/lib/tapioca/dsl/compilers/identity_cache.rb index 6680b010b..96a354fa1 100644 --- a/lib/tapioca/dsl/compilers/identity_cache.rb +++ b/lib/tapioca/dsl/compilers/identity_cache.rb @@ -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( diff --git a/spec/tapioca/dsl/compilers/identity_cache_spec.rb b/spec/tapioca/dsl/compilers/identity_cache_spec.rb index 570c4d11b..7f8060381 100644 --- a/spec/tapioca/dsl/compilers/identity_cache_spec.rb +++ b/spec/tapioca/dsl/compilers/identity_cache_spec.rb @@ -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]) } @@ -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)) } @@ -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]) } @@ -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)) }