Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to rails 7 and thinking sphinx 5.6.0 getting Arel::Visitors::UnsupportedVisitError: Unsupported argument type: NilClass. Construct an Arel node instead. (Arel::Visitors::UnsupportedVisitError) #1267

Open
gauravseth opened this issue Dec 1, 2024 · 6 comments

Comments

@gauravseth
Copy link

I am upgrading my project to rails 7.0.8.6 and ruby 3.3.5. I have installed thinking-sphinx 5.6.0. When running indexing i am getting Arel::Visitors::UnsupportedVisitError: Unsupported argument type: NilClass. Construct an Arel node instead. (Arel::Visitors::UnsupportedVisitError)

home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:760:in `unsupported'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/visitor.rb:30:in `visit'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:563:in `visit_Arel_Nodes_On'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/visitor.rb:30:in `visit'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:540:in `visit_Arel_Nodes_OuterJoin'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/visitor.rb:30:in `visit'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:827:in `block in inject_join'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:825:in `each'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:825:in `each_with_index'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:825:in `inject_join'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:512:in `visit_Arel_Nodes_JoinSource'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/visitor.rb:30:in `visit'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:156:in `visit_Arel_Nodes_SelectCore'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/mysql.rb:30:in `visit_Arel_Nodes_SelectCore'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:124:in `block in visit_Arel_Nodes_SelectStatement'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:123:in `each'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:123:in `inject'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:123:in `visit_Arel_Nodes_SelectStatement'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/mysql.rb:25:in `visit_Arel_Nodes_SelectStatement'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/visitor.rb:30:in `visit'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/visitor.rb:11:in `accept'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/arel/visitors/to_sql.rb:18:in `compile'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/active_record/connection_adapters/abstract/database_statements.rb:37:in `to_sql_and_binds'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/active_record/connection_adapters/abstract/database_statements.rb:13:in `to_sql'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/active_record/relation.rb:732:in `block in to_sql'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/active_record/connection_adapters/abstract_adapter.rb:277:in `unprepared_statement'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/activerecord-7.0.8.6/lib/active_record/relation.rb:732:in `to_sql'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/active_record/sql_builder.rb:13:in `sql_query'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/active_record/sql_source.rb:140:in `build_sql_query'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/active_record/sql_source.rb:165:in `prepare_for_render'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/active_record/sql_source.rb:83:in `render'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/riddle-2.4.3/lib/riddle/configuration/index.rb:30:in `block in render'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/riddle-2.4.3/lib/riddle/configuration/index.rb:30:in `collect'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/riddle-2.4.3/lib/riddle/configuration/index.rb:30:in `render'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/core/index.rb:74:in `render'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/riddle-2.4.3/lib/riddle/configuration.rb:45:in `block in render'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/riddle-2.4.3/lib/riddle/configuration.rb:45:in `collect'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/riddle-2.4.3/lib/riddle/configuration.rb:45:in `render'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/configuration.rb:111:in `render'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/configuration.rb:119:in `block in render_to_file'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/configuration.rb:119:in `open'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/configuration.rb:119:in `render_to_file'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/commands/configure.rb:7:in `call'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/commands/base.rb:11:in `call_with_handling'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/commands/base.rb:7:in `call'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/commander.rb:7:in `call'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/interfaces/base.rb:9:in `command'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/interfaces/sql.rb:25:in `index'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/thinking-sphinx-5.6.0/lib/thinking_sphinx/tasks.rb:49:in `block (3 levels) in <top (required)>'
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/rake-13.2.1/exe/rake:27:in `<top (required)>'
/home/gaurav/.rvm/gems/ruby-3.3.5/bin/ruby_executable_hooks:22:in `eval'
/home/gaurav/.rvm/gems/ruby-3.3.5/bin/ruby_executable_hooks:22:in `<main>'
Tasks: TOP => ts:index => ts:sql:index

Same version of sphinx is running on rails 5.2.3 and ruby 2.5.7.
i am not sure if i need do modify anything.

@gauravseth
Copy link
Author

Please suggest some solution to try.

@pat
Copy link
Owner

pat commented Dec 4, 2024

Can you confirm what version of joiner is in your Gemfile.lock file? You will need v0.6.0 for Rails 6+.

@gauravseth
Copy link
Author

gauravseth commented Dec 5, 2024

Can you confirm what version of joiner is in your Gemfile.lock file? You will need v0.6.0 for Rails 6+.
joiner (0.6.0) is getting used.

I tried now joiner 0.5.0 but it is giving below Error

NoMethodError: undefined method `construct_tables!' for an instance of Joiner::JoinDependency (NoMethodError)

    construct_tables! join_root
    ^^^^^^^^^^^^^^^^^
Did you mean?  construct
/home/gaurav/.rvm/gems/ruby-3.3.5/gems/joiner-0.5.0/lib/joiner/join_dependency.rb:4:in `join_association_for'

@pat
Copy link
Owner

pat commented Dec 5, 2024

Definitely stick with joiner 0.6.0.

Can you share your index definition? Do you know which one is causing the problem? I realise the error message doesn't provide any clues - is it possible to comment out most indices, to see whether it's just one that's the cause?

@gauravseth
Copy link
Author

gauravseth commented Dec 6, 2024

Thanks for reply it is really helpful to debug further. below index line is causing error
indexes agent_1_wo_cond.company_name, :as => :agent_1_v, :sortable => true

below line is present in model
belongs_to :agent_1_wo_cond, -> { customer_unscoped }, :class_name => 'CompanyDetail', :foreign_key => 'agent_1_id'

This line is in other model

scope :customer_unscoped, -> { unscope(:where)}

@gauravseth
Copy link
Author

This issue occurs when there s default scope and trying to unscope it in association. and same is getting used in indexing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants