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

Fix type of column_type parameter for handle_unknown_type method #997

Merged
merged 2 commits into from
Jun 16, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def as_nilable_type(type)
end
end

sig { params(column_type: Object).returns(String) }
sig { params(column_type: BasicObject).returns(String) }
def handle_unknown_type(column_type)
return "T.untyped" unless ActiveModel::Type::Value === column_type
return "T.untyped" if Runtime::GenericTypeRegistry.generic_type_instance?(column_type)
Expand Down
8 changes: 8 additions & 0 deletions spec/tapioca/dsl/compilers/active_record_columns_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def title?; end
t.boolean :boolean_column
t.datetime :datetime_column
t.decimal :money_column
t.text :serialized_column
end
end
end
Expand All @@ -235,6 +236,7 @@ def title?; end

class Post < ActiveRecord::Base
money_column(:money_column, currency: "USD")
serialize :serialized_column, JSON
end
RUBY

Expand Down Expand Up @@ -287,6 +289,12 @@ def datetime_column=(value); end
def money_column=(value); end
RBI
assert_includes(output, expected)

expected = indented(<<~RBI, 4)
sig { params(value: T.untyped).returns(T.untyped) }
def serialized_column=(value); end
RBI
assert_includes(output, expected)
end

it "falls back to generating BigDecimal for money column if MoneyColumn is not defined" do
Expand Down