Restream / redmine_tagging

Add simple tagging support to Redmine Issues/Wiki pages
114 stars 50 forks source link

Prolem with plugin on redmine 3.3.0 - Unknown column 'projects.status' in 'where clause' #71

Closed arnisjuraga closed 8 years ago

arnisjuraga commented 8 years ago

When searching in Redmine, we receive an error:

Started GET "/ri/projects/project-name?utf8=%E2%9C%93&q=jira" for 192.168.1.1 at 2016-08-15 20:45:41 +0300
Processing by SearchController#index as HTML
  Parameters: {"utf8"=>"✓", "q"=>"jira", "id"=>"project-name"}
  Current user: arnis@domain.name (id=4)
Completed 500 Internal Server Error in 50ms (ActiveRecord: 21.2ms)

ActiveRecord::StatementInvalid (Mysql2::Error: Unknown column 'projects.status' in 'where clause': SELECT DISTINCT `wiki_pages`.`created_on`, `wiki_pages`.`id` FROM `wiki_pages` LEFT OUTER JOIN `wiki_page_tags` ON `wiki_page_tags`.`wiki_page_id` = `wiki_pages`.`id` WHERE (projects.status <> 9 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='wiki')) AND (wikis.project_id IN (192)) AND (((title LIKE '%jira%') OR (wiki_contents.text LIKE '%jira%') OR (wiki_page_tags.tag LIKE '%jira%')))  ORDER BY `wiki_pages`.`created_on` DESC, `wiki_pages`.`id` DESC):
  lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb:171:in `fetch_ranks_and_ids'
  lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb:91:in `search_result_ranks_and_ids'
  lib/redmine/search.rb:127:in `block in load_result_ids'
  lib/redmine/search.rb:125:in `each'
  lib/redmine/search.rb:125:in `load_result_ids'
  lib/redmine/search.rb:115:in `block in load_result_ids_from_cache'
  lib/redmine/search.rb:114:in `load_result_ids_from_cache'
  lib/redmine/search.rb:99:in `result_ids'
  lib/redmine/search.rb:70:in `result_count'
  app/controllers/search_controller.rb:75:in `index'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'
andybrucenet commented 8 years ago

Hi I run into this same problem only when searching Wiki pages. Issues / Documents search OK.

The error shows as arnisjuraga comments above.

If I had more time I would fix the problem; it appears to be straightforward in setting up the LEFT OUTER JOIN. I just don't understand how to modify scope correctly.

Comment out the offending section in plugins/redmine_tagging/init.rb and wiki search works:

ActionDispatch::Callbacks.to_prepare do
[...cut...]
  unless WikiPage.searchable_options[:include] && WikiPage.searchable_options[:include].include?(:wiki_page_tags)
#    WikiPage.searchable_options[:columns] << "#{WikiPageTag.table_name}.tag"
#
#    # For redmine < 3
#    WikiPage.searchable_options[:include] ||= []
#    WikiPage.searchable_options[:include] << :wiki_page_tags
#
#    # For redmine > 3
#    WikiPage.searchable_options[:scope] = proc { WikiPage.includes(:wiki_page_tags) }
  end
end
thegcat commented 8 years ago

This should be fixed by #72.