File tree Expand file tree Collapse file tree
lib/active_record/connection_adapters
spec/active_record/connection_adapters/oracle_enhanced Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1062,13 +1062,16 @@ def resolve_database_aliases
10621062 end
10631063
10641064 if @config [ :database ] . to_s . start_with? ( "/" )
1065+ trimmed = @config [ :database ] . to_s . delete_prefix ( "/" )
10651066 OracleEnhanced . deprecator . warn (
10661067 "Setting `:database` to a value that starts with `/` " \
10671068 "(#{ @config [ :database ] . inspect } ) is deprecated and will raise " \
10681069 "in a future major version. The leading slash is an adapter " \
10691070 "artefact from when `:database` was prepended into an EZCONNECT " \
1070- "URL; the slash is no longer needed. Use the same value without " \
1071- "the leading `/`, or use the explicit `:service_name` option."
1071+ "URL; the slash is no longer needed. Use `database: " \
1072+ "#{ trimmed . inspect } ` or `service_name: #{ trimmed . inspect } ` " \
1073+ "instead (no leading slash on either)." ,
1074+ caller_locations ( 2 )
10721075 )
10731076 end
10741077 end
Original file line number Diff line number Diff line change @@ -138,9 +138,11 @@ def session_cursor_sharing(connection)
138138 end
139139
140140 it "should connect to database using service_name" do
141- ActiveRecord ::Base . establish_connection ( SERVICE_NAME_CONNECTION_PARAMS )
142- expect ( ActiveRecord ::Base . lease_connection ) . not_to be_nil
143- expect ( ActiveRecord ::Base . lease_connection . class ) . to eq ( ActiveRecord ::ConnectionAdapters ::OracleEnhancedAdapter )
141+ ActiveRecord ::ConnectionAdapters ::OracleEnhanced . deprecator . silence do
142+ ActiveRecord ::Base . establish_connection ( SERVICE_NAME_CONNECTION_PARAMS )
143+ expect ( ActiveRecord ::Base . lease_connection ) . not_to be_nil
144+ expect ( ActiveRecord ::Base . lease_connection . class ) . to eq ( ActiveRecord ::ConnectionAdapters ::OracleEnhancedAdapter )
145+ end
144146 end
145147end
146148
@@ -346,7 +348,16 @@ def session_cursor_sharing(connection)
346348 ActiveRecord ::Base . establish_connection ( CONNECTION_PARAMS . merge ( database : "/#{ DATABASE_NAME } " ) )
347349 expect {
348350 ActiveRecord ::Base . lease_connection
349- } . to output ( /DEPRECATION WARNING: Setting `:database` to a value that starts with `\/ `.*:service_name/m ) . to_stderr
351+ } . to output (
352+ %r{DEPRECATION WARNING: Setting `:database`.*starts with `/`.*database: "#{ DATABASE_NAME } ".*service_name: "#{ DATABASE_NAME } "}mo
353+ ) . to_stderr
354+ end
355+
356+ it "points the 'called from' frame at the user's call site, not adapter internals" do
357+ ActiveRecord ::Base . establish_connection ( CONNECTION_PARAMS . merge ( database : "/#{ DATABASE_NAME } " ) )
358+ expect {
359+ ActiveRecord ::Base . lease_connection
360+ } . to output ( %r{called from .*\b connection_spec\. rb:\d +} ) . to_stderr
350361 end
351362
352363 it "does not warn when :database has no leading slash" do
You can’t perform that action at this time.
0 commit comments