Skip to content

Commit 429accf

Browse files
wpolicarpoLavika
authored and
Lavika
committed
Fix appname resolution when outside Rails context (rails-sqlserver#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 rails-sqlserver#942.
1 parent 5dc5817 commit 429accf

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ def config_appname(config)
142142
end
143143

144144
def rails_application_name
145-
return nil if Rails.application.nil?
146-
147145
Rails.application.class.name.split("::").first
146+
rescue
147+
nil # Might not be in a Rails context so we fallback to `nil`.
148148
end
149149

150150
def config_login_timeout(config)

0 commit comments

Comments
 (0)