Skip to content

Compatibility with activerecord-tenanted #276

@chrise86

Description

@chrise86

The naming may be a little misleading here, as the following issue occurs when trying to annotate tenanted models, even though the error comes from the UntenantedConnectionPool class:

Annotating models
/Users/chris/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/bundler/gems/rails-cf6b3107753a/activerecord/lib/active_record/model_schema.rb:540:in 'ActiveRecord::ModelSchema::ClassMethods#reset_column_information': undefined method 'active_connection' for an instance of ActiveRecord::Tenanted::UntenantedConnectionPool (NoMethodError)

        connection_pool.active_connection&.clear_cache!
                       ^^^^^^^^^^^^^^^^^^
	from /Users/chris/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/bundler/gems/annotaterb-dd101d201e94/lib/annotate_rb/model_annotator/project_annotator.rb:42:in 'AnnotateRb::ModelAnnotator::ProjectAnnotator#build_instructions_for_file'
	from /Users/chris/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/bundler/gems/annotaterb-dd101d201e94/lib/annotate_rb/model_annotator/project_annotator.rb:17:in 'block in AnnotateRb::ModelAnnotator::ProjectAnnotator#annotate'
	from /Users/chris/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/bundler/gems/annotaterb-dd101d201e94/lib/annotate_rb/model_annotator/project_annotator.rb:13:in 'Array#map'
	from /Users/chris/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/bundler/gems/annotaterb-dd101d201e94/lib/annotate_rb/model_annotator/project_annotator.rb:13:in 'AnnotateRb::ModelAnnotator::ProjectAnnotator#annotate'
	from /Users/chris/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/bundler/gems/annotaterb-dd101d201e94/lib/annotate_rb/model_annotator/annotator.rb:21:in 'AnnotateRb::ModelAnnotator::Annotator#do_annotations'
	from /Users/chris/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/bundler/gems/annotaterb-dd101d201e94/lib/annotate_rb/model_annotator/annotator.rb:8:in 'AnnotateRb::ModelAnnotator::Annotator.do_annotations'
	from /Users/chris/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/bundler/gems/annotaterb-dd101d201e94/lib/annotate_rb/commands/annotate_models.rb:17:in 'AnnotateRb::Commands::AnnotateModels#call'
	from /Users/chris/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/bundler/gems/annotaterb-dd101d201e94/lib/annotate_rb/runner.rb:38:in 'AnnotateRb::Runner#run'
	from /Users/chris/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/bundler/gems/annotaterb-dd101d201e94/lib/annotate_rb/runner.rb:11:in 'AnnotateRb::Runner.run'
	from /Users/chris/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/bundler/gems/annotaterb-dd101d201e94/exe/annotaterb:18:in '<top (required)>'
	from bin/annotate:16:in 'Kernel#load'
	from bin/annotate:16:in '<main>'

Calling .reset_column_information on a tenanted model within the Rails console works fine, but a default tenant is set automatically and I think this issue is likely to do with no tenant being loaded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions