Skip to content

Commit 434514a

Browse files
authored
Fix appname resolution when outside Rails context (#943)
The adapter can be used outside a Rails context so TinyTDS appname config should be able to be resolved if a Rails application was not detected. Fix #942.
1 parent 89f90b6 commit 434514a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Unreleased
2+
3+
#### Fixed
4+
5+
- [#943](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/943) Fix appname resolution when outside Rails context
6+
17
## v6.1.2.0
28

39
[Full changelog](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/compare/v6.1.1.0...v6.1.2.0)

lib/active_record/connection_adapters/sqlserver_adapter.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ def config_appname(config)
119119
end
120120

121121
def rails_application_name
122-
return nil if Rails.application.nil?
123-
124122
Rails.application.class.name.split("::").first
123+
rescue
124+
nil # Might not be in a Rails context so we fallback to `nil`.
125125
end
126126

127127
def config_login_timeout(config)

0 commit comments

Comments
 (0)