alchemy_cms: upgrader 6.0 crashing in create_ingredients

Steps to reproduce

bundle exec rake alchemy:upgrade:6.0:create_ingredients

Expected behavior

It should not crash, but migrate essences to ingredients.

Actual behavior

It raises an error

Create ingredients for elements with ingredients defined
--------------------------------------------------------
rake aborted!
ActiveRecord::EagerLoadPolymorphicError: Cannot eagerly load the polymorphic association :essence
/Users/robin/.rvm/gems/ruby-2.7.1/gems/ransack-2.4.1/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb:24:in `block in build'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/ransack-2.4.1/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb:6:in `each'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/ransack-2.4.1/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb:6:in `map'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/ransack-2.4.1/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb:6:in `build'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/ransack-2.4.1/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb:26:in `block in build'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/ransack-2.4.1/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb:6:in `each'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/ransack-2.4.1/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb:6:in `map'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/ransack-2.4.1/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb:6:in `build'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/associations/join_dependency.rb:69:in `initialize'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/query_methods.rb:1063:in `new'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/query_methods.rb:1063:in `construct_join_dependency'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/query_methods.rb:1126:in `build_join_dependencies'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/query_methods.rb:1112:in `each_join_dependencies'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/query_methods.rb:1106:in `lookup_table_klass_from_join_dependencies'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/query_methods.rb:1092:in `block in build_where_clause'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/table_metadata.rb:39:in `associated_table'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/predicate_builder.rb:86:in `block in expand_from_hash'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/predicate_builder.rb:84:in `each'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/predicate_builder.rb:84:in `flat_map'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/predicate_builder.rb:84:in `expand_from_hash'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/predicate_builder.rb:29:in `build_from_hash'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/query_methods.rb:1091:in `build_where_clause'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/query_methods.rb:645:in `where!'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activerecord-6.1.3.2/lib/active_record/relation/query_methods.rb:640:in `where'
/Users/robin/.rvm/gems/ruby-2.7.1/bundler/gems/alchemy_cms-5fcf414caa99/lib/alchemy/upgrader/tasks/ingredients_migrator.rb:20:in `block in create_ingredients'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/atomic/abstract_thread_local_var.rb:43:in `bind'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/activesupport-6.1.3.2/lib/active_support/deprecation/reporting.rb:41:in `silence'
/Users/robin/.rvm/gems/ruby-2.7.1/bundler/gems/alchemy_cms-5fcf414caa99/lib/alchemy/upgrader/tasks/ingredients_migrator.rb:11:in `create_ingredients'
/Users/robin/.rvm/gems/ruby-2.7.1/bundler/gems/alchemy_cms-5fcf414caa99/lib/alchemy/upgrader/six_point_zero.rb:16:in `create_ingredients'
/Users/robin/.rvm/gems/ruby-2.7.1/bundler/gems/alchemy_cms-5fcf414caa99/lib/tasks/alchemy/upgrade.rake:85:in `block (4 levels) in <main>'
/Users/robin/.rvm/gems/ruby-2.7.1/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/Users/robin/.rvm/gems/ruby-2.7.1/bin/ruby_executable_hooks:24:in `eval'
/Users/robin/.rvm/gems/ruby-2.7.1/bin/ruby_executable_hooks:24:in `<main>'
Tasks: TOP => alchemy:upgrade:6.0:create_ingredients
(See full trace by running task with --trace)

System configuration

  • Alchemy Version: latest main branch
  • Rails Version: 6.1 (its not officially supported yet, I just hope we can discuss this issue anyways)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 18 (17 by maintainers)

Commits related to this issue

Most upvoted comments

I stripped my elements.yml down to the simplest element I have. It doesn’t matter what element I use, it behaves the same for all of those I’ve tried.

My stripped elements.yml looks like this

- name: event_list
  ingredients:
    - role: headline
      type: Text

running the rake task fails on this line

all_elements = Alchemy::Element
  .named(elements_with_ingredients.map { |d| d[:name] })
  .includes(contents: { essence: :ingredient_association })
  .left_outer_joins(:ingredients).where(alchemy_ingredients: { id: nil })
  .to_a

edit: Just saw I could also use ENV[‘ONLY’] to do the same…