Project

General

Profile

Actions

Defect #5288

closed

sql error for null root_ids in app/controllers/timelog_controller.rb

Added by Burt Culver about 14 years ago. Updated about 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Time tracking
Target version:
-
Start date:
2010-04-10
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid
Affected version:

Description

I just upgraded to redmine trunk r3630 from r3200. When I tried to view the time_entries on an issue I got an SQL error in timelog_controller.

database version - mysql 5.1
Ruby version - ruby 1.8.6 (2007-03-13 patchlevel 0) [x86_64-linux]
Rails version - rails-2.3.5
Redmine version - r3630

Processing TimelogController#details (for 118.93.234.188 at 2010-04-10 19:47:23) [GET]
  Parameters: {"project_id"=>"bgz", "action"=>"details", "issue_id"=>"11023", "controller"=>"timelog"}

ActiveRecord::StatementInvalid (Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND issues.lft >= 9 AND issues.rgt <= 14) AND (spent_on BETWEEN '2006-01-31' AND' at line 1: SELECT count(DISTINCT `time_entries`.id) AS count_all FROM `time_entries`  LEFT OUTER JOIN `projects` ON `projects`.id = `time_entries`.project_id  LEFT OUTER JOIN `issues` ON `issues`.id = `time_entries`.issue_id WHERE (1=1 AND (issues.root_id =  AND issues.lft >= 9 AND issues.rgt <= 14) AND (spent_on BETWEEN '2006-01-31' AND '2010-05-30')) AND (projects.status=1 AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='time_tracking')) ):
  app/controllers/timelog_controller.rb:179:in `details'
  app/controllers/timelog_controller.rb:176:in `details'
  app/models/time_entry.rb:81:in `visible_by'
  app/models/time_entry.rb:80:in `visible_by'
  app/controllers/timelog_controller.rb:175:in `details'
  passenger (2.2.4) lib/phusion_passenger/rack/request_handler.rb:91:in `process_request'
  passenger (2.2.4) lib/phusion_passenger/abstract_request_handler.rb:206:in `main_loop'
  passenger (2.2.4) lib/phusion_passenger/railz/application_spawner.rb:376:in `start_request_handler'
  passenger (2.2.4) lib/phusion_passenger/railz/application_spawner.rb:334:in `handle_spawn_application'
  passenger (2.2.4) lib/phusion_passenger/utils.rb:182:in `safe_fork'
  passenger (2.2.4) lib/phusion_passenger/railz/application_spawner.rb:332:in `handle_spawn_application'
  passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in `__send__'
  passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in `main_loop'
  passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:195:in `start_synchronously'
  passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:162:in `start'
  passenger (2.2.4) lib/phusion_passenger/railz/application_spawner.rb:213:in `start'
  passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:261:in `spawn_rails_application'
  passenger (2.2.4) lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
  passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application'
  passenger (2.2.4) lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
  passenger (2.2.4) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
  passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:254:in `spawn_rails_application'
  passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:153:in `spawn_application'
  passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:286:in `handle_spawn_application'
  passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in `__send__'
  passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in `main_loop'
  passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:195:in `start_synchronously'

Rendering /mnt/redminevol/redmine_upgraded10Apr10/public/500.html (500 Internal Server Error)

The root_id is NULL so it is causing the sql error. After I updated the issue I could view the time_entries. Most likely because update_nested_set_attributes had been called on it and the root_id was set to the issue_id.

This is only an issue for checking time on tickets that haven't been updated since our redmine upgrade.

Actions #1

Updated by Jean-Philippe Lang about 14 years ago

I can not reproduce. The root_id column for all issues was updated by the AddIssuesNestedSetsColumns migration and should not be NULL.
Were you using the subtasks plugin before migrating to r3630?

Actions #2

Updated by Burt Culver about 14 years ago

Jean-Philippe Lang wrote:

I can not reproduce. The root_id column for all issues was updated by the AddIssuesNestedSetsColumns migration and should not be NULL.
Were you using the subtasks plugin before migrating to r3630?

yes, I was.

Actions #3

Updated by Burt Culver about 14 years ago

Burt Culver wrote:

Jean-Philippe Lang wrote:

I can not reproduce. The root_id column for all issues was updated by the AddIssuesNestedSetsColumns migration and should not be NULL.
Were you using the subtasks plugin before migrating to r3630?

yes, I was.

and I did have problems with that migration. I see - I may have skipped "Issue.update_all("parent_id = NULL, root_id = id, lft = 1, rgt = 2")" from that file by accident.

Actions #4

Updated by Burt Culver about 14 years ago

  • Status changed from New to Resolved

yes, running "update issues set lft = 1, rgt = 2, root_id = id WHERE parent_id is NULL" by hand fixed the problem. Thanks.

Actions #5

Updated by Jean-Philippe Lang about 14 years ago

  • Status changed from Resolved to Closed
  • Resolution set to Invalid

Thanks for the feedback.

Actions

Also available in: Atom PDF