diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2017-08-29 16:48:33 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2017-08-29 16:50:51 +0900 |
commit | c3b2d7117c6b5aede95e9126c4c0cb48bca0739b (patch) | |
tree | 61eda2817eb34b2b9151910d7ad4aac6804cf9d2 /railties | |
parent | ca941da4002bb604bc7fef7bedcff8428bd5dc08 (diff) | |
download | rails-c3b2d7117c6b5aede95e9126c4c0cb48bca0739b.tar.gz rails-c3b2d7117c6b5aede95e9126c4c0cb48bca0739b.tar.bz2 rails-c3b2d7117c6b5aede95e9126c4c0cb48bca0739b.zip |
Fix `can't modify frozen String` error in `DBConsole`
Without this, `dbconsole` raises an error as follwing:
```
RuntimeError: can't modify frozen String
railties/lib/rails/commands/dbconsole/dbconsole_command.rb:79:in `start'
```
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/commands/dbconsole/dbconsole_command.rb | 2 | ||||
-rw-r--r-- | railties/test/commands/dbconsole_test.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/railties/lib/rails/commands/dbconsole/dbconsole_command.rb b/railties/lib/rails/commands/dbconsole/dbconsole_command.rb index 6296c95a87..5234969743 100644 --- a/railties/lib/rails/commands/dbconsole/dbconsole_command.rb +++ b/railties/lib/rails/commands/dbconsole/dbconsole_command.rb @@ -75,7 +75,7 @@ module Rails args += ["-P", "#{config['password']}"] if config["password"] if config["host"] - host_arg = "#{config['host']}" + host_arg = "#{config['host']}".dup host_arg << ":#{config['port']}" if config["port"] args += ["-S", host_arg] end diff --git a/railties/test/commands/dbconsole_test.rb b/railties/test/commands/dbconsole_test.rb index e922a23e15..6ad96b28c7 100644 --- a/railties/test/commands/dbconsole_test.rb +++ b/railties/test/commands/dbconsole_test.rb @@ -206,6 +206,12 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase assert_equal ["sqlplus", "user/secret@db"], dbconsole.find_cmd_and_exec_args end + def test_sqlserver + start(adapter: "sqlserver", database: "db", username: "user", password: "secret", host: "localhost", port: 1433) + assert_not aborted + assert_equal ["sqsh", "-D", "db", "-U", "user", "-P", "secret", "-S", "localhost:1433"], dbconsole.find_cmd_and_exec_args + end + def test_unknown_command_line_client start(adapter: "unknown", database: "db") assert aborted |