提交 0a99fddc 编写于 作者: M Matthew Draper

Complete change of `sqlite3:///` path handling

That which was now relative is now absolute.
上级 f846828d
* As promised, switch `sqlite3:///` URLs (which were temporarily
deprecated in 4.1) from relative to absolute.
If you still want the previous interpretation, you should replace
`sqlite3:///my/path` with `sqlite3:my/path`.
*Matthew Draper*
* (Temporarily) deprecate SQLite database URLs containing an * (Temporarily) deprecate SQLite database URLs containing an
authority. authority.
......
...@@ -41,7 +41,6 @@ def initialize(url) ...@@ -41,7 +41,6 @@ def initialize(url)
else else
@query = @uri.query @query = @uri.query
end end
@authority = url =~ %r{\A[^:]*://}
end end
# Converts the given URL to a full connection hash. # Converts the given URL to a full connection hash.
...@@ -91,21 +90,8 @@ def raw_config ...@@ -91,21 +90,8 @@ def raw_config
end end
# Returns name of the database. # Returns name of the database.
# Sqlite3's handling of a leading slash is in transition as of
# Rails 4.1.
def database_from_path def database_from_path
if @authority && @adapter == 'sqlite3' if @adapter == 'sqlite3'
# 'sqlite3:///foo' is relative, for backwards compatibility.
database_name = uri.path.sub(%r{^/}, "")
msg = "Paths in SQLite3 database URLs of the form `sqlite3:///path` will be treated as absolute in Rails 4.2. " \
"Please switch to `sqlite3:#{database_name}`."
ActiveSupport::Deprecation.warn(msg)
database_name
elsif @adapter == 'sqlite3'
# 'sqlite3:/foo' is absolute, because that makes sense. The # 'sqlite3:/foo' is absolute, because that makes sense. The
# corresponding relative version, 'sqlite3:foo', is handled # corresponding relative version, 'sqlite3:foo', is handled
# elsewhere, as an "opaque". # elsewhere, as an "opaque".
......
...@@ -83,8 +83,8 @@ def test_encoded_password ...@@ -83,8 +83,8 @@ def test_encoded_password
end end
def test_url_with_authority_for_sqlite3 def test_url_with_authority_for_sqlite3
spec = assert_deprecated { resolve 'sqlite3:///foo_test' } spec = resolve 'sqlite3:///foo_test'
assert_equal('foo_test', spec["database"]) assert_equal('/foo_test', spec["database"])
end end
def test_url_absolute_path_for_sqlite3 def test_url_absolute_path_for_sqlite3
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册