Skip to content

Commit 8f33191

Browse files
Support trust_server_certificate option in dbconsole
Co-authored-by: Justin Dell <jdell@hey.com>
1 parent 58e7ac1 commit 8f33191

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def dbconsole(config, options = {})
104104
args += ["-d", config.database.to_s] if config.database
105105
args += ["-U", sqlserver_config[:username].to_s] if sqlserver_config[:username]
106106
args += ["-P", sqlserver_config[:password].to_s] if sqlserver_config[:password]
107+
args += ["-C"] if sqlserver_config[:trust_server_certificate]
107108

108109
if sqlserver_config[:host]
109110
host_arg = "tcp:#{sqlserver_config[:host]}"
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# frozen_string_literal: true
22

33
class DbConsole < ActiveRecord::TestCase
4-
subject { ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter }
4+
subject { ActiveRecord::ConnectionAdapters::SQLServerAdapter }
55

6-
it "uses sqlplus to connect to database" do
7-
subject.expects(:find_cmd_and_exec).with("sqlcmd", "-d", "db", "-U", "user", "-P", "secret", "-S", "tcp:localhost,1433")
6+
it "uses sqlcmd to connect to database" do
7+
subject.expects(:find_cmd_and_exec).with("sqlcmd", "-d", "db", "-U", "user", "-P", "secret", "-C", "-S",
8+
"tcp:localhost,1433")
89

9-
config = make_db_config(adapter: "sqlserver", database: "db", username: "user", password: "secret", host: "localhost", port: 1433)
10+
config = make_db_config(adapter: "sqlserver", database: "db", username: "user", password: "secret",
11+
host: "localhost", port: 1433, trust_server_certificate: true)
1012

1113
subject.dbconsole(config)
1214
end

0 commit comments

Comments
 (0)