Skip to content

ActiveContext: invalidate current adapter active connection changes

The following discussion from !182729 (merged) should be addressed:

  • @maddievn started a discussion: (+1 comment)

    Maybe this doesn't have to be done now, but should we invalidate the current adapter when there's a change to the active connection? I.e. when it changes from one record to another, when the options/adapter_class of the active record changes, etc.

    ActiveContext::Adapter.current.connection.name
    => "os1"
    
    ActiveContext::Config.connection_model.update_all(active: false)
    
    ActiveContext::Adapter.current.connection.name
    => "os1"
    
    ActiveContext::Config.connection_model.where(name: "pg1").first.update(active: true)
    => true
    
    ActiveContext::Adapter.current.connection.name
    => "os1"

    When I restart the console

    ActiveContext::Adapter.current.connection.name
    => "pg1"
OSZAR »