Edgewall Software
Modify

Opened 15 years ago

Closed 15 years ago

#8566 closed defect (fixed)

bugzilla2trac.py: Components / Versions from too many bugzilla products get imported

Reported by: remke.rutgers@… Owned by: Remy Blank
Priority: normal Milestone: 0.12
Component: ticket system Version: 0.12dev
Severity: normal Keywords: bugzilla2trac
Cc: remke.rutgers@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Selecting multiple PRODUCTS and COMPONENTS_FROM_PRODUCTS = False converts too many components from Bugzilla to Trac.

Software versions I use:

  • Python: 2.3.4
  • Bugzilla: 3.0.2
  • Mysql: 4.0.18
  • Trac: 0.10.4
  • bugzilla2trac.py: revision 8272
  • MySQL-python: 1.2.1_p2

My setup (partial):

COMPONENTS_FROM_PRODUCTS = False
PRODUCTS = ["Product1","Product2","Product3"]

This results in the conversion of too many components: also components NOT belonging to Product1, Product2 or Product3 get imported.

By printing the select clause for components (line 570) I found out the issue is with the generated where clause for components: line 574:

sql += makeWhereClause('p.name', PRODUCTS)

This results in a where clause in the following form

p.name = 'Product1' or p.name = 'Product2' or p.name = 'Product3'

However, there are not parentheses around this where clause, which results in too many components getting selected.

I think any where clause generated by makeWhereClause(…) should result in a where clause surrounded by parentheses.

I fixed the problem by modifying line 498 in the makeWhereClause function: from

return ' ' + clause

to

 return ' (' + clause + ') '

Can someone please review this change and (if accepted) apply it to bugzilla2trac.py?

Attachments (1)

8566-bugzilla2trac-r8702.patch (2.5 KB ) - added by Remy Blank 15 years ago.
Untested patch fixing both issues.

Download all attachments as: .zip

Change History (6)

comment:1 by hieroglyph, 15 years ago

Summary: bugzilla2trac.py: Components from too many bugzilla products get importedbugzilla2trac.py: Components / Versions from too many bugzilla products get imported

I found the same problem and answer today, now I find that the same also applies to the imported version labels. I had to change the existing SQL:

        sql = """SELECT DISTINCTROW versions.value AS value
                               FROM products, versions"""
        sql += " WHERE" + makeWhereClause('products.name', PRODUCTS)

…to

        sql = """SELECT DISTINCTROW v.value AS value
                 FROM products p, versions v
                 WHERE v.product_id = p.id AND ("""
        sql += makeWhereClause('p.name', PRODUCTS) + ")"

Note: I am wrapping the makeWhereClause in brackets in the sql instead of inside the function as op suggested (I cannot see a problem with either approach?) but this does not solve the version label problem by itself.

by Remy Blank, 15 years ago

Untested patch fixing both issues.

comment:2 by Remy Blank, 15 years ago

Owner: set to Remy Blank

The patch above should fix both issues. Unfortunately, I have no way of testing it. I will apply it for 0.12 if I get some positive reports that it works and fixes the two issues discussed here.

comment:3 by anonymous, 15 years ago

I applied the patch and re-ran the import: I can confirm the components issue is fixed. I cannot say anything about the versions, because we are not using versions.

comment:4 by Remy Blank, 15 years ago

Thanks for the feedback! I'll wait a few more days and see if I can get a reply from hieroglyph as well.

comment:5 by Remy Blank, 15 years ago

Resolution: fixed
Status: newclosed

Patch applied in [8743].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.