View Issue Details

IDProjectCategoryView StatusLast Update
0012680mantisbtcustom fieldspublic2014-09-23 18:05
Reportermatt77 Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.3 
Target Version1.2.9Fixed in Version1.2.9 
Summary0012680: Custom field name with paranthesis leads to db error message when sorting "view issues"
Description

Follow the steps to reproduce. An error message appears starting with

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(field) FROM mantis_project_table [...]"

Steps To Reproduce

Create a custom field with paranthesis, e.g. "My custom (field)".
Add it to your project's "view issues" view in My Account --> Manage Columns.
Go to that project's "view issues" view.
Klick on the column header "My custom (field)"

TagsNo tags attached.

Relationships

related to 0012404 closeddregad custom field sort issue on view issues page 
related to 0015721 closedgrangeway Functionality to consider porting to master-2.0.x 
has duplicate 0008323 closeddregad Spaces in custom fields 
related to 0012170 closeddregad SQL syntax error occurs when sorting it by the custom field where special character is included. 

Activities

matt77

matt77

2011-01-12 04:28

reporter   ~0027909

Temporary solution is to remove the paranthesis. Sorting works just fine afterwards

Dentxinho

Dentxinho

2011-08-31 13:41

reporter   ~0029606

Possible fixes on filter_api.php:920

1) Quote the alias (non-standard SQL):
Change line to
$c_cf_alias = "'" . strreplace( ' ', '', $t_custom_field ) . "'";

2) Ignore the actual name of the field, and use another string for the alias. IMO is better to use the custom field ID:
$c_cf_alias = "custom_fieldalias" . $t_custom_field_id;

dregad

dregad

2011-12-07 13:38

developer   ~0030494

@Dentxinho, thanks for the suggestion for the fix.

Dentxinho

Dentxinho

2011-12-07 14:30

reporter   ~0030496

You're welcome.

BTW, Github changesets are not attached to bugs anymore?

dregad

dregad

2011-12-07 19:30

developer   ~0030508

I think there's a problem with the source control plugin for github atm, which prevents changesets from being attached automatically. jreese has not had time to figure out exactly what it is and fix the code yet, so they are loaded manually every once in a while.

grangeway

grangeway

2013-04-05 17:57

reporter   ~0036242

Marking as 'acknowledged' not resolved/closed to track that change gets ported to master-2.0.x branch

Related Changesets

MantisBT: master 170e9397

2011-12-07 04:55

dregad


Details Diff
Define custom field alias using id instead of name

The old method of defining a custom field alias based on the field's
name, generated SQL syntax error when trying to sort on that field in
the view issues page, if the name contains characters not valid for an
SQL identifier (e.g. '-', '(', ')', etc).

Fixes 0012404, 0012680
Affected Issues
0012404, 0012680
mod - core/filter_api.php Diff File

MantisBT: master-1.2.x 8fb27ae7

2011-12-07 04:55

dregad


Details Diff
Define custom field alias using id instead of name

The old method of defining a custom field alias based on the field's
name, generated SQL syntax error when trying to sort on that field in
the view issues page, if the name contains characters not valid for an
SQL identifier (e.g. '-', '(', ')', etc).

Fixes 0012404, 0012680
Affected Issues
0012404, 0012680
mod - core/filter_api.php Diff File