View Issue Details

IDProjectCategoryView StatusLast Update
0016259mantisbtbugtrackerpublic2017-08-23 16:54
Reportermaschneider Assigned Todregad  
PrioritynormalSeveritytweakReproducibilityalways
Status closedResolutionfixed 
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
Description

If 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 Information

due_date is a int field and undefied is 1 and 1 is alway bevor current timestamp

TagsNo tags attached.

Relationships

related to 0023241 closedcproensa Error when changing sort order in filters, due date field only 

Activities

maschneider

maschneider

2013-08-11 09:54

reporter   ~0037654

I fix the bug, and create a pull request:

https://github.com/mantisbt/mantisbt/pull/92

please review and merged

dregad

dregad

2013-08-20 17:26

developer   ~0037901

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...

atrol

atrol

2013-08-21 02:55

developer   ~0037904

Also a bit strange at this place
<pre>
if ( 'last_updated' == $c_sort ) {
$c_sort = "last_updated";
}
</pre>

dregad

dregad

2013-08-21 03:31

developer   ~0037905

Last edited: 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

maschneider

maschneider

2013-08-21 04:07

reporter   ~0037906

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?

dregad

dregad

2013-08-28 18:19

developer   ~0037944

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.

dregad

dregad

2013-10-12 17:02

developer   ~0038247

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

2013-07-12 00:00

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
Affected Issues
0016259
mod - core/filter_api.php Diff File

MantisBT: master 044133b3

2013-07-12 00:00

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
Affected Issues
0016259
mod - core/filter_api.php Diff File

MantisBT: master-1.2.x 017eca50

2013-08-20 06:28

dregad


Details Diff
Remove useless code Affected Issues
0016259
mod - core/filter_api.php Diff File

MantisBT: master 5c4f817a

2013-08-20 06:28

dregad


Details Diff
Remove useless code Affected Issues
0016259
mod - core/filter_api.php Diff File

MantisBT: master-1.2.x fa52c994

2013-08-20 13:46

dregad


Details Diff
due_date ASC sort: pgsql fix

Fix 0016259: adding order by expression to select list to avoid error.
Affected Issues
0016259
mod - core/filter_api.php Diff File

MantisBT: master 174878c3

2013-08-20 13:46

dregad


Details Diff
due_date ASC sort: pgsql fix

Fix 0016259: adding order by expression to select list to avoid error.
Affected Issues
0016259
mod - core/filter_api.php Diff File

MantisBT: master 9c57416c

2013-08-20 13:48

dregad


Details Diff
Remove DISTINCT clause from filter_get_bug_rows query

Fixes 0016259 PostgreSQL error when filtering by due_date ASC
Affected Issues
0016259
mod - core/filter_api.php Diff File

MantisBT: master a451d135

2013-10-12 13:04

dregad


Details Diff
Revert "Remove DISTINCT clause from filter_get_bug_rows query"

This reverts commit 9c57416cc20d82cb6af1ff6852011e33f988981b.

Issue 0016259
Affected Issues
0016259
mod - core/filter_api.php Diff File