View Issue Details

IDProjectCategoryView StatusLast Update
0005419mantisbtsqlpublic2005-04-18 10:38
Reportercsaba Assigned Tothraxisp  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version0.19.2 
Fixed in Version1.0.0a1 
Summary0005419: Odd use of SELECT DISTINCT
Description

In user_api.php there is a
$query = DISTINCT ( id ), name FROM $t_project_table ...
and a
$query = DISTINCT ( p.id ), name FROM $t_project_table p LEFT JOIN ...

Also, this construct with the parentheses happens with category in print_api.php, only there it takes the form:
SELECT DISTINCT( category ) as category ...

I have two issues with the first form:

  1. id is unique within $_project_table. Hence DISTINCT does not seem to serve a purpose there.
  2. Second, and more importantly, with this kind of construct, the field that SQLite returns is not 'id' but rather '( id )' which is somewhat awkward. One possible solution would be to select based on position (0). Another would be to use the AS id construct analagous to what category is doing above. I don't know the ramifications on the query or with other databases, though.

Csaba Gabor from Vienna

TagsNo tags attached.

Activities

thraxisp

thraxisp

2005-04-10 22:26

reporter   ~0009781

Fixed in CVS.

core/print_api.php ->1.126
core/project_hierarchy_api.php ->1.5
core/user_api.php -> 1.95
graphs/graph_by_release_delta.php -> 1.9