FIX: Allow Symbol objects to be deserialized in PostRevision (stable) (#17512)

Followup to bb287c6c74
This commit is contained in:
David Taylor 2022-07-15 13:16:20 +01:00 committed by GitHub
parent 5d2ecce3f6
commit f0ef186a4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -246,7 +246,7 @@ module Discourse
# see: http://stackoverflow.com/questions/11894180/how-does-one-correctly-add-custom-sql-dml-in-migrations/11894420#11894420
config.active_record.schema_format = :sql
config.active_record.yaml_column_permitted_classes = [Hash, HashWithIndifferentAccess, Time]
config.active_record.yaml_column_permitted_classes = [Hash, HashWithIndifferentAccess, Time, Symbol]
# We use this in development-mode only (see development.rb)
config.active_record.use_schema_cache_dump = false

View File

@ -23,4 +23,15 @@ describe PostRevision do
}
)
end
it "can serialize and deserialize symbols" do
# Plugins may store symbolized values in this column
pr = Fabricate(:post_revision, modifications: { key: :value })
pr.reload
expect(pr.modifications).to eq(
{
key: :value
}
)
end
end