[Sugar-devel] [PATCH v3 sugar-datastore 1/2] find(): fix sort order in ambiguous cases
Sascha Silbe
silbe at activitycentral.com
Tue May 1 14:11:23 EDT 2012
When several entries have the same timestamp, the exact ordering when sorting
by timestamp was undefined previously. That's good enough for most clients, but
a test suite needs repeatable results. We make sure the ordering is stable by
sorting by the automatically-assigned, strictly increasing Xapian document id
in the matching direction.
Signed-off-by: Sascha Silbe <silbe at activitycentral.com>
---
v2->v3: Better handling of unsupported order_by values, as pointed out
by Simon
src/carquinyol/indexstore.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/carquinyol/indexstore.py b/src/carquinyol/indexstore.py
index dc721e7..7e7bfb5 100644
--- a/src/carquinyol/indexstore.py
+++ b/src/carquinyol/indexstore.py
@@ -301,8 +301,10 @@ class IndexStore(object):
if order_by == '+timestamp':
enquire.set_sort_by_value(_VALUE_TIMESTAMP, True)
+ enquire.set_docid_order(False)
elif order_by == '-timestamp':
enquire.set_sort_by_value(_VALUE_TIMESTAMP, False)
+ enquire.set_docid_order(True)
elif order_by == '+title':
enquire.set_sort_by_value(_VALUE_TITLE, True)
elif order_by == '-title':
@@ -316,7 +318,10 @@ class IndexStore(object):
elif order_by == '-creation_time':
enquire.set_sort_by_value(_VALUE_CREATION_TIME, False)
else:
- logging.warning('Unsupported property for sorting: %s', order_by)
+ logging.warning('Sorting by property %r is not supported, falling'
+ ' back to default (+timestamp)', order_by)
+ enquire.set_sort_by_value(_VALUE_TIMESTAMP, True)
+ enquire.set_docid_order(False)
query_result = enquire.get_mset(offset, limit, check_at_least)
total_count = query_result.get_matches_estimated()
--
1.7.9.5
More information about the Sugar-devel
mailing list