Reset column info after making Topic tz-aware #35271
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #35194.
This is a really strange bug.
For some reason,
.reload_schema_from_cache
called byTopic.reset_column_information
can change how date time columns behave. It seems to change included modules ofActiveRecord::Type::DateTime
instances, but only sometimes.In the expected flow, the value cast starts here and includes
[ActiveRecord::Type::Internal::Timezone, #<ActiveModel::Type::Helpers::AcceptsMultiparameterTime:0x00007f8cae260358>, ActiveModel::Type::Helpers::TimeValue, ActiveSupport::ToJsonWithActiveSupportEncoder, ActiveSupport::Dependencies::Loadable, JSON::Ext::Generator::GeneratorMethods::Object, ActiveSupport::Tryable, Kernel]
. In the failing test case, the value cast starts here and includes[ActiveSupport::Tryable, #<Module:0x00007f8b010f1e58>]
.This seems to be triggered by initializing a new topic in
AttributeMethodsTest#test_YAML_dumping_a_record_with_time_zone-aware_attribute
after resetting column info in a previous test. My proposed solution is more of a band-aid to minimize the blast radius of attribute changes between tests (this was already being done for other tests inAttributeMethodsTest
).