提交 8aaf9719 编写于 作者: L Lars Kanis

Postgresql: add test case for setting custom libpq connection parameters

上级 8ee6406a
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
module ActiveRecord module ActiveRecord
class PostgresqlConnectionTest < ActiveRecord::TestCase class PostgresqlConnectionTest < ActiveRecord::TestCase
class NonExistentTable < ActiveRecord::Base
end
def setup def setup
super super
@connection = ActiveRecord::Base.connection @connection = ActiveRecord::Base.connection
...@@ -10,5 +13,17 @@ def setup ...@@ -10,5 +13,17 @@ def setup
def test_encoding def test_encoding
assert_not_nil @connection.encoding assert_not_nil @connection.encoding
end end
# Ensure, we can set connection params using the example of Generic
# Query Optimizer (geqo). It is 'on' per default.
def test_connection_options
params = ActiveRecord::Base.connection_config.dup
params[:options] = "-c geqo=off"
NonExistentTable.establish_connection(params)
# Verify the connection param has been applied.
expect = NonExistentTable.connection.query('show geqo').first.first
assert_equal 'off', expect
end
end end
end end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册