[opensuse-buildservice] Can't force delete project after upgrade to OBS 1.5
In the delete branch of SourceController.index_project, which is invoked when deleting a project, if the code enters the force branch, a MySQL InvalidStatement occurs on the last line of the following block: SourceController < ApplicationController ... def index_project ... pro = DbProject.find_by_name project_name ... #find linking repos lreps = Array.new pro.repositories.each do |repo| repo.linking_repositories.each do |lrep| lreps << lrep end end if lreps.length > 0 if params[:force] and not params[:force].empty? #replace links to this projects with links to the "deleted" project del_repo = DbProject.find_by_name("deleted").repositories[0] lreps.each do |link_rep| pe = link_rep.path_elements.find(:first, :include => ["link"], :conditions => ["db_project_id = ?", pro.id]) The error is ActiveRecord::StatementInvalid (Mysql::Error: Unknown column 'db_project_id' in 'where clause': SELECT * FROM `path_elements` WHERE (`path_elements`.parent_id = 2756 AND (db_project_id = 1871)) ORDER BY position LIMIT 1) db_project_id is a not a column in path_elements, so somehow a JOIN is not being generated by the ActiveRecord base class for PathElements. Does anyone know how to fix it so the generated MySQL correctly JOINs in the tables that have db_project_id? -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
If I changed the :include to a :joins: pe = link_rep.path_elements.find(:first, :joins => ["link"], :conditions => ["db_project_id = ?", project.id]) then it works. This results in the MySQL: SELECT `path_elements`.* FROM `path_elements` INNER JOIN `repositories` ON `repositories`.id = `path_elements`.repository_id WHERE (`path_elements`.parent_id = 137 AND (db_project_id = 132)) ORDER BY position LIMIT 1 However, the unchanged code appears to work just for the public OBS (I could delete a linked to repository under my home), so why do I need to change the :include to a :joins? Luke Imhoff wrote:
In the delete branch of SourceController.index_project, which is invoked when deleting a project, if the code enters the force branch, a MySQL InvalidStatement occurs on the last line of the following block:
SourceController < ApplicationController ... def index_project ... pro = DbProject.find_by_name project_name ... #find linking repos lreps = Array.new pro.repositories.each do |repo| repo.linking_repositories.each do |lrep| lreps << lrep end end
if lreps.length > 0 if params[:force] and not params[:force].empty? #replace links to this projects with links to the "deleted" project del_repo = DbProject.find_by_name("deleted").repositories[0] lreps.each do |link_rep| pe = link_rep.path_elements.find(:first, :include => ["link"], :conditions => ["db_project_id = ?", pro.id])
The error is ActiveRecord::StatementInvalid (Mysql::Error: Unknown column 'db_project_id' in 'where clause': SELECT * FROM `path_elements` WHERE (`path_elements`.parent_id = 2756 AND (db_project_id = 1871)) ORDER BY position LIMIT 1)
db_project_id is a not a column in path_elements, so somehow a JOIN is not being generated by the ActiveRecord base class for PathElements.
Does anyone know how to fix it so the generated MySQL correctly JOINs in the tables that have db_project_id?
-- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
participants (1)
-
Luke Imhoff