Closed
Bug 245849
Opened 20 years ago
Closed 20 years ago
Sort columns doesn't work if fields are null
Categories
(Calendar :: Sunbird Only, defect)
Calendar
Sunbird Only
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: gekacheka, Assigned: mostafah)
References
Details
Attachments
(1 file)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040514 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040514 Sort columns doesn't seem to work if some events have null field value, but does work if all have a value. Reproducible: Always Steps to Reproduce: 1. Create several events with "test" in the title 2. Create events without setting the title 3. sort today's events by title (click title column header) 4. type "test" in the "contains" field 5. sort today's events by title. Actual Results: When the events with null title were included, sort did not work. When only events with "test" in the title were included, sort did work. Expected Results: null title should be treated as empty string. Problem may be because: "" < "A" --> true null < "A" --> false Fix may be in unifinder function sortEvents, wrap EventA.title and EventA.location with nullToEmpty(...) where nullToEmpty is function nullToEmpty(string) { return string == null? "" : string; }
Need at least 2 events with null values to see the null value problem. 'Location' is a field which may often be null. The problem arises because a comparison with null always returns false, so sort doesn't work. null < "A" --> false "A" < null --> false Another problem is the previous compare function never returned 0, so sort was not stable when items are equal. Stable sort is important for sorting by multiple columns. For example, to sort by date and by priority, just click the priority column and then the date column. This works if the sort is stable, so the items within the same date stay in the same priority order. A minor nit is clicking on a date sorted the null/00 date earliest, but it may be an incomplete task which would be better sorted as if the date was 'now'. Changes: Added function compareString which converts nulls into "" before comparing them, and returns 0 for equal strings. Added function compareNumber which converts nulls into 0 before comparing them, and returns 0 for equal numbers. Added function compareDate which converts nulls and the 0000-00-00 00:00:00 time into the 'now' time when the sort started, so that incomplete undated tasks sort to now. The treeView.sortStartedTime is updated once just before each sort so that holds the current 'now' but does not change during the sort. Renamed sortEvents(a,b) to compareEvents(a,b). Renamed sortTasks(a,b) to compareTasks(a,b). Rewrote compareEvents and compareTasks to call the compareString, compareNumber, and compareDate functions. Testing: Sorting each column works on both 1.7rc3 Suite and 1.8a2 Sunbird. Stability will come as soon as bug 224128 is fixed.
Assignee | ||
Comment 2•20 years ago
|
||
Checked in. Thanks
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Comment 3•18 years ago
|
||
The bugspam monkeys have been set free and are feeding on Calendar :: Sunbird Only. Be afraid for your sanity!
QA Contact: gurganbl → sunbird
You need to log in
before you can comment on or make changes to this bug.
Description
•