Commit cf407144 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'fix-disable_prepared_statements' into 'master'

Fix `Connection#disable_prepared_statements` loosing connection qualifier

See merge request gitlab-org/gitlab!69753
parents 36302fb6 6706148b
......@@ -88,7 +88,16 @@ module Gitlab
# Disables prepared statements for the current database connection.
def disable_prepared_statements
scope.establish_connection(config.merge(prepared_statements: false))
db_config_object = scope.connection_db_config
config = db_config_object.configuration_hash.merge(prepared_statements: false)
hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(
db_config_object.env_name,
db_config_object.name,
config
)
scope.establish_connection(hash_config)
end
# Check whether the underlying database is in read-only mode
......
......@@ -162,6 +162,12 @@ RSpec.describe Gitlab::Database::Connection do
expect(connection.scope.connection.prepared_statements).to eq(false)
end
it 'retains the connection name' do
connection.disable_prepared_statements
expect(connection.scope.connection_db_config.name).to eq('main')
end
context 'with dynamic connection pool size' do
before do
connection.scope.establish_connection(connection.config.merge(pool: 7))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment