Roundup Tracker - Issues

Message7142

Author rouilj
Recipients ngaba, rouilj, schlatterbeck
Date 2021-03-27.03:59:21
Message-id <1616817563.05.0.683440581413.issue2551122@roundup.psfhosted.org>
In-reply-to
Details and discussion in thread including:

  https://sourceforge.net/p/roundup/mailman/message/37247607/

short form:

sorted method uses:

  value.sort(key=lambda a:a[property], reverse=reverse)

but a[property] is always a string so you get 1, 12, 2, 21, 22 etc.

Need to covert a[property] into it's actual declared type.
Hyperdb has a sort_repr(cls, a[property], property) method
for just this purpose. However there is no method defined for
Integer or Number. Define one for Integer and Number returning
int(val) or float(val) respectively. Also need to handle case
where value (a[property] is None) (see issue2551120) as this
causes a crash.

Extensive discussion on how to handle None state and set it to some
value that will allow the sort to work is inconclusive so far.
I suggest using int(sys.maxint || sys.maxsize) (python2/3)
and float('inf'). This should sort unknown to the end.

Once sort_repr is done for Integer and Float something like:

   cls = self._db.getclass(self._prop.classname)
   sort_repr = cls.property.sort_repr # (or maybe cls[property])
   value.sort(key=lambda a:sort_repr(cls, a[property], property),
              reverse=reverse)

but I am not sure what self is passed to sort_repr.

Problem found by ngaba.
History
Date User Action Args
2021-03-27 03:59:23rouiljsetrecipients: + rouilj, schlatterbeck, ngaba
2021-03-27 03:59:23rouiljsetmessageid: <1616817563.05.0.683440581413.issue2551122@roundup.psfhosted.org>
2021-03-27 03:59:23rouiljlinkissue2551122 messages
2021-03-27 03:59:21rouiljcreate