Mailinglist Archive: opensuse-buildservice (312 mails)

< Previous Next >
Re: [opensuse-buildservice] Can't force delete project after upgrade to OBS 1.5
  • From: Luke Imhoff <luke@xxxxxxxx>
  • Date: Mon, 13 Jul 2009 11:21:04 -0500
  • Message-id: <4A5B5EF0.8070600@xxxxxxxx>
If I changed the :include to a :joins:

pe = link_rep.path_elements.find(:first, :joins => ["link"], :conditions => ["db_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 =
pro.repositories.each do |repo|
repo.linking_repositories.each do |lrep|
lreps << lrep

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 = ?",])

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@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-buildservice+help@xxxxxxxxxxxx

< Previous Next >
This Thread