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

ActiveModel DateTime Attribute is a Time, not a DateTime #1036

Merged
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/active_model_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def type_for(attribute_type_value)
when ActiveModel::Type::Date
"::Date"
when ActiveModel::Type::DateTime, ActiveModel::Type::Time
"::DateTime"
"::Time"
when ActiveModel::Type::Decimal
"::BigDecimal"
when ActiveModel::Type::Float
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def type_for(column_name)
when ActiveRecord::Type::Boolean
"T::Boolean"
when ActiveRecord::Type::DateTime, ActiveRecord::Type::Time
"::DateTime"
"::Time"
when ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter
"::ActiveSupport::TimeWithZone"
else
Expand Down
4 changes: 2 additions & 2 deletions spec/tapioca/dsl/compilers/active_model_attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ class Shop
# typed: strong

class Shop
sig { returns(T.nilable(::DateTime)) }
sig { returns(T.nilable(::Time)) }
def created_at; end

sig { params(value: T.nilable(::DateTime)).returns(T.nilable(::DateTime)) }
sig { params(value: T.nilable(::Time)).returns(T.nilable(::Time)) }
def created_at=(value); end

sig { returns(T.nilable(::Integer)) }
Expand Down
2 changes: 1 addition & 1 deletion spec/tapioca/dsl/compilers/active_record_columns_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def boolean_column=(value); end
assert_includes(output, expected)

expected = indented(<<~RBI, 4)
sig { params(value: T.nilable(::DateTime)).returns(T.nilable(::DateTime)) }
sig { params(value: T.nilable(::Time)).returns(T.nilable(::Time)) }
def datetime_column=(value); end
RBI
assert_includes(output, expected)
Expand Down