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:
parent
a2bd669ed2
commit
e5f1b363d2
2 changed files with 29 additions and 0 deletions
|
@ -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 }
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue