Page 1 of 1

Bad query for advanced filter view

Posted: 11 Jan 2006, 22:04
by mlovell
Hello,

I'm playing with Mantis 1.1.0-CVS (from the CVS tarball available on
11 Jan 2005), and I'm having some difficulty with advanced filters.
I believe I'm having the same problem with 1.0.0rc4, although I
have not verified that.

With a completely new installation of mantis, I've created a simple
project and populated it with only two issues. The initial Simple Filter
view works wonderfully, even handling the custom field (Color) added
to the project. Here is the initial SQL query formed by that page:

Code: Select all

SELECT DISTINCT mantis_bug_table.id AS id FROM mantis_project_table,  mantis_bug_table WHERE mantis_project_table.enabled = 1 AND mantis_project_table.id = mantis_bug_table.project_id AND ( mantis_bug_table.status in (10, 20, 30, 40, 50, 80) )
The above query occurs when I'm logged into "All projects". From there,
clicking on Advanced Filters causes the following query:

Code: Select all

SELECT DISTINCT mantis_bug_table.id AS id FROM mantis_project_table, mantis_bug_table WHERE mantis_project_table.enabled = 1 AND mantis_project_table.id = mantis_bug_table.project_id AND ( mantis_bug_table.project_id=-3 )
If I switch into the single project available (which has a project_if of 1)
the Advanced Filter query changes to the following:

Code: Select all

SELECT DISTINCT mantis_bug_table.id AS id FROM mantis_project_table, mantis_bug_table WHERE mantis_project_table.enabled = 1 AND mantis_project_table.id = mantis_bug_table.project_id AND ( mantis_bug_table.project_id=1 ) AND ( mantis_bug_table.project_id=-3 )
Where is the -3 coming from?

Looking briefly at the initial code in filter_get_bug_rows(), I can't help but
notice that there is an ALL_PROJECTS test if $t_view_type is "simple", but no corresponding code for $t_view_type == "advanced". Is this omission intentional? Even considering that difference, however, I cannot determine where the -3 is originating. The code that forms that query seems identical for simple and advanced filtering:

Code: Select all

  if (1 == count( $t_projects ) ) {
    $t_project = $t_projects[0];
    array_push( $t_where_clauses, "( $t_bug_table.project_id=$t_project )");

I would appreciate any help. I'm running on RHEL4 with 4.3.9, MySQL 4.1.12, and Apache 2.0.52.

Posted: 12 Jan 2006, 00:30
by mlovell
This is what I get for looking at the tip of CVS...

I believe this is fixed in the head of BRANCH_1_0_0rc4.