瀏覽代碼

Bugfix in mongodb datasource select ordering

They were a bug when ordering stuff contains 2 values that are equals
Yann Weber 8 年之前
父節點
當前提交
f4c88e9555
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4
    4
      lodel/plugins/mongodb_datasource/datasource.py

+ 4
- 4
lodel/plugins/mongodb_datasource/datasource.py 查看文件

@@ -115,9 +115,9 @@ class MongoDbDatasource(AbstractDatasource):
115 115
             #Here we may implement the group
116 116
             #If sorted query we have to sort again
117 117
             if order is not None:
118
-                results = sorted(results,
119
-                    key=functools.cmp_to_key(
120
-                        self.__generate_lambda_cmp_order(order)))
118
+                key_fun = functools.cmp_to_key(
119
+                    self.__generate_lambda_cmp_order(order))
120
+                results = sorted(results, key=key_fun)
121 121
             #If limit given apply limit again
122 122
             if offset > len(results):
123 123
                 results = list()
@@ -851,7 +851,7 @@ field/operator couple in a query. We will keep only the first one")
851 851
         glco = cls.__generate_lambda_cmp_order
852 852
         fname, cmpdir = order[0]
853 853
         order = order[1:]
854
-        return lambda a,b: glco(order) if a[fname] == b[fname] else (\
854
+        return lambda a,b: glco(order)(a,b) if a[fname] == b[fname] else (\
855 855
             1 if (a[fname]>b[fname] if cmpdir == 'ASC' else a[fname]<b[fname])\
856 856
             else -1)
857 857
 

Loading…
取消
儲存