1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Revert "Remove Marshal support from SchemaCache"

This reverts commit 65f2eeaaf5.
This commit is contained in:
Rafael Mendonça França 2019-03-13 14:08:54 -04:00
parent a2bd669ed2
commit e5f1b363d2
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948
2 changed files with 29 additions and 0 deletions

View file

@ -114,6 +114,17 @@ module ActiveRecord
@indexes.delete name
end
def marshal_dump
# if we get current version during initialization, it happens stack over flow.
@version = connection.migration_context.current_version
[@version, @columns, @columns_hash, @primary_keys, @data_sources, @indexes]
end
def marshal_load(array)
@version, @columns, @columns_hash, @primary_keys, @data_sources, @indexes = array
@indexes = @indexes || {}
end
private
def prepare_data_sources
connection.data_sources.each { |source| @data_sources[source] = true }

View file

@ -86,6 +86,24 @@ module ActiveRecord
assert_equal 0, @cache.size
end
def test_dump_and_load
@cache.columns("posts")
@cache.columns_hash("posts")
@cache.data_sources("posts")
@cache.primary_keys("posts")
@cache.indexes("posts")
@cache = Marshal.load(Marshal.dump(@cache))
assert_no_queries do
assert_equal 12, @cache.columns("posts").size
assert_equal 12, @cache.columns_hash("posts").size
assert @cache.data_sources("posts")
assert_equal "id", @cache.primary_keys("posts")
assert_equal 1, @cache.indexes("posts").size
end
end
def test_data_source_exist
assert @cache.data_source_exists?("posts")
assert_not @cache.data_source_exists?("foo")