MantisBT

View Issue Details Jump to Notes ] Wiki ] Related Changesets ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0016259mantisbtbugtrackerpublic2013-08-11 09:532014-02-07 18:24
Reportermaschneider 
Assigned Todregad 
PrioritynormalSeveritytweakReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version1.2.15 
Target Version1.2.16Fixed in Version1.2.16 
Summary0016259: When sorting issues by due_date, unset values should be listed at the end
DescriptionIf you have enable due_date and you want to sort than to see the bugs with the first due_date you get the bugs without due_date instead.
Additional Informationdue_date is a int field and undefied is 1 and 1 is alway bevor current timestamp
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
User avatar (0037654)
maschneider (reporter)
2013-08-11 09:54

I fix the bug, and create a pull request:

https://github.com/mantisbt/mantisbt/pull/92 [^]

please review and merged
User avatar (0037901)
dregad (developer)
2013-08-20 17:26

I just tested your patch, and while it works fine with MySQL, it breaks PostgreSQL when sorting by due_date ASC -

APPLICATION ERROR 401

Database query failed. Error received from database was #-1: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ...AND ( mantis_bug_table.project_id = 1 ) ORDER BY mantis_bug...
^ for the query: SELECT DISTINCT mantis_bug_table.* FROM mantis_bug_table JOIN mantis_project_table ON mantis_project_table.id = mantis_bug_table.project_id WHERE mantis_project_table.enabled = ? AND ( mantis_bug_table.project_id = 1 ) ORDER BY mantis_bug_table.due_date = 1, mantis_bug_table.due_date ASC, mantis_bug_table.last_updated DESC, mantis_bug_table.date_submitted DESC.

So the fix you propose can't be applied as it is.

A possible solution/workaround for this issue could be to add '(due_date = 1)' to the list of selected columns, but I think the *real* question is, why are we doing a SELECT DISTINCT here ? It does not make much sense to me to do so, as it would appear that a normal SELECT should do the job just fine.

But then again messing with the filter_api always feels like opening a can of worms...
User avatar (0037904)
atrol (developer)
2013-08-21 02:55

Also a bit strange at this place
if ( 'last_updated' == $c_sort ) {
$c_sort = "last_updated";
}
User avatar (0037905)
dregad (developer)
2013-08-21 03:31
edited on: 2013-08-28 18:22

@atrol, yeah I saw that, this useless code will be removed eventually

==> see commits: master 5c4f817a, master-1.2.x 017eca50

User avatar (0037906)
maschneider (reporter)
2013-08-21 04:07

We can not remove "DISTINCT" in the SELECT may be it will break some plugins with JOINS (i dont know it it is ever used)

The DISTINCT is not necessary for the JOIN with the mantis_bug_table and not with the LEFT JOIN of customer fields

Maybe adding "(due_date = 1) as has_due_date" to the select?
User avatar (0037944)
dregad (developer)
2013-08-28 18:19

In my opinion, the best option in the long term is to get rid of the DISTINCT.

However, it is also potentially a more hazardous approach; therefore to minimize the risk of introducing a regression in 1.2 branch, I'll follow the more conservative approach of adding an additional column to the select for the sort.

For 1.3 branch, I'll remove the DISTINCT instead, and we can see down the line if that breaks something.
User avatar (0038247)
dregad (developer)
2013-10-12 17:02

It turns out @maschneider was right... I did some testing on the master branch today, and without the distinct we do get multiple rows, e.g. when filtering bugs having more than one bugnote with text matching the search filter.

I'll revert the 1.3 fix and port the 1.2 commit.

- Related Changesets
MantisBT: master-1.2.x 7a375d64
Timestamp: 2013-07-12 04:00:20
Author: da_ms
Committer: dregad
Details ] Diff ]
When sorting by due_date, display undefined values last

Markus' original patch was modified to simplify the code and reduce
duplication, fix a couple typos in comment text and reword the
commit message.

Fixes 0016259
mod - core/filter_api.php Diff ] File ]
MantisBT: master 044133b3
Timestamp: 2013-07-12 04:00:20
Author: da_ms
Committer: dregad
Details ] Diff ]
When sorting by due_date, display undefined values last

Markus' original patch was modified to simplify the code and reduce
duplication, fix a couple typos in comment text and reword the
commit message.

Fixes 0016259
mod - core/filter_api.php Diff ] File ]
MantisBT: master-1.2.x 017eca50
Timestamp: 2013-08-20 10:28:39
Author: dregad
Details ] Diff ]
Remove useless code
mod - core/filter_api.php Diff ] File ]
MantisBT: master 5c4f817a
Timestamp: 2013-08-20 10:28:39
Author: dregad
Details ] Diff ]
Remove useless code
mod - core/filter_api.php Diff ] File ]
MantisBT: master-1.2.x fa52c994
Timestamp: 2013-08-20 17:46:32
Author: dregad
Details ] Diff ]
due_date ASC sort: pgsql fix

Fix 0016259: adding order by expression to select list to avoid error.
mod - core/filter_api.php Diff ] File ]
MantisBT: master 174878c3
Timestamp: 2013-08-20 17:46:32
Author: dregad
Details ] Diff ]
due_date ASC sort: pgsql fix

Fix 0016259: adding order by expression to select list to avoid error.
mod - core/filter_api.php Diff ] File ]
MantisBT: master 9c57416c
Timestamp: 2013-08-20 17:48:03
Author: dregad
Details ] Diff ]
Remove DISTINCT clause from filter_get_bug_rows query

Fixes 0016259 PostgreSQL error when filtering by due_date ASC
mod - core/filter_api.php Diff ] File ]
MantisBT: master a451d135
Timestamp: 2013-10-12 17:04:22
Author: dregad
Details ] Diff ]
Revert "Remove DISTINCT clause from filter_get_bug_rows query"

This reverts commit 9c57416cc20d82cb6af1ff6852011e33f988981b.

Issue 0016259
mod - core/filter_api.php Diff ] File ]

- Issue History
Date Modified Username Field Change
2013-08-11 09:53 maschneider New Issue
2013-08-11 09:54 maschneider Note Added: 0037654
2013-08-14 08:36 MishaMart Issue cloned: 0016271
2013-08-16 04:38 hero2289 Tag Attached: closed
2013-08-16 06:33 atrol Tag Detached: closed
2013-08-20 11:20 dregad Assigned To => dregad
2013-08-20 11:20 dregad Status new => assigned
2013-08-20 11:20 dregad Category db mysql => bugtracker
2013-08-20 11:20 dregad Target Version => 1.2.16
2013-08-20 11:20 dregad Summary add sorting of due_date ASC to display not set always last => When sorting issues by due_date, unset values should be listed at the end
2013-08-20 17:26 dregad Note Added: 0037901
2013-08-20 17:26 dregad Status assigned => feedback
2013-08-21 02:55 atrol Note Added: 0037904
2013-08-21 03:31 dregad Note Added: 0037905
2013-08-21 04:07 maschneider Note Added: 0037906
2013-08-21 04:07 maschneider Status feedback => assigned
2013-08-28 18:17 dregad Changeset attached => MantisBT master-1.2.x 7a375d64
2013-08-28 18:17 dregad Changeset attached => MantisBT master-1.2.x fa52c994
2013-08-28 18:17 dregad Status assigned => resolved
2013-08-28 18:17 dregad Resolution open => fixed
2013-08-28 18:17 dregad Fixed in Version => 1.2.16
2013-08-28 18:17 dregad Changeset attached => MantisBT master 044133b3
2013-08-28 18:17 dregad Changeset attached => MantisBT master 9c57416c
2013-08-28 18:19 dregad Note Added: 0037944
2013-08-28 18:21 dregad Changeset attached => MantisBT master-1.2.x 017eca50
2013-08-28 18:21 dregad Changeset attached => MantisBT master 5c4f817a
2013-08-28 18:22 dregad Note Edited: 0037905 View Revisions
2013-10-12 17:02 dregad Note Added: 0038247
2013-10-12 17:02 dregad Status resolved => feedback
2013-10-12 17:02 dregad Resolution fixed => reopened
2013-10-12 18:28 dregad Changeset attached => MantisBT master a451d135
2013-10-12 18:28 dregad Changeset attached => MantisBT master 174878c3
2013-10-12 18:28 dregad Status feedback => resolved
2013-10-12 18:34 dregad Resolution reopened => fixed
2014-02-07 18:24 dregad Status resolved => closed


MantisBT 1.2.17 [^]
Copyright © 2000 - 2014 MantisBT Team
Time: 0.2147 seconds.
memory usage: 3,171 KB
Powered by Mantis Bugtracker