View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0019670 | mantisbt | filters | public | 2015-04-27 23:01 | 2015-09-06 17:37 |
Reporter | vboctor | Assigned To | vboctor | ||
Priority | normal | Severity | major | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Product Version | 1.3.0-beta.2 | ||||
Target Version | 1.3.0-beta.3 | Fixed in Version | 1.3.0-beta.3 | ||
Summary | 0019670: View Issues page fails when a custom field is used for filtering and sorting | ||||
Description | If the same custom field is used for filtering to a value that is not "any" and is also used for sorting, the generated query defines the same table alias twice causing a SQL error. The fix is to use different aliasing prefix for filtering vs. sorting. This generates invalid queries like ones quoted in 0019667 | ||||
Tags | mantishub | ||||
Reminder sent to: atrol, dregad Interesting bug for 1.3 relating to filter API creating invalid queries. |
|
Error message: APPLICATION ERROR # 401 Here is a sample broken query: SELECT Count( DISTINCT mantis_bug_table.id ) as idcnt FROM mantis_bug_table JOIN mantis_project_table ON mantis_project_table.id = mantis_bug_table.project_id LEFT JOIN mantis_custom_field_string_table mantis_custom_field_string_table_12 ON mantis_bug_table.id = mantis_custom_field_string_table_12.bug_id AND mantis_custom_field_string_table_12.field_id = 12 LEFT JOIN mantis_custom_field_string_table mantis_custom_field_string_table_5 ON mantis_bug_table.id = mantis_custom_field_string_table_5.bug_id AND mantis_custom_field_string_table_5.field_id = 5 LEFT JOIN mantis_custom_field_string_table mantis_custom_field_string_table_3 ON mantis_bug_table.id = mantis_custom_field_string_table_3.bug_id AND mantis_custom_field_string_table_3.field_id = 3 LEFT JOIN mantis_custom_field_string_table mantis_custom_field_string_table_2 ON mantis_bug_table.id = mantis_custom_field_string_table_2.bug_id AND mantis_custom_field_string_table_2.field_id = 2 LEFT JOIN mantis_custom_field_string_table mantis_custom_field_string_table_13 ON mantis_bug_table.id = mantis_custom_field_string_table_13.bug_id AND mantis_custom_field_string_table_13.field_id = 13 LEFT JOIN mantis_custom_field_string_table mantis_custom_field_string_table_14 ON |
|
The tablename_id is used for aliasing, such table names are not expected. I suspect that mantis_custom_field_string_table_5 is the cause of the issue, since it is referenced twice. |
|
I've revised the issue title and description to reflect the root cause. I'll submit a pull request shortly. |
|
Here is the pull request: |
|
MantisBT: master 53ee0c74 2015-04-27 20:12 Details Diff |
Fix SQL error when custom field is in filter/sort If the same custom field is used for filtering to a value that is not "any" and is also used for sorting, the generated query defines the same table alias twice causing a SQL error. The fix is to use different aliasing prefix for filtering vs. sorting. Fixes 0019670 |
Affected Issues 0019670 |
|
mod - core/filter_api.php | Diff File |