Browse Source

Possible overflow bug fix in mongodb datasource

In post reccursion processing on select
Yann Weber 8 years ago
parent
commit
229293b734
1 changed files with 7 additions and 2 deletions
  1. 7
    2
      plugins/mongodb_datasource/datasource.py

+ 7
- 2
plugins/mongodb_datasource/datasource.py View File

120
                     results, key=operator.itemgetter(*sort_itemgetter_args),
120
                     results, key=operator.itemgetter(*sort_itemgetter_args),
121
                     reverse=False if sort_dir == 'ASC' else True)
121
                     reverse=False if sort_dir == 'ASC' else True)
122
             #If limit given apply limit again
122
             #If limit given apply limit again
123
-            if limit is not None:
124
-                results = results[offset:offset+limit]
123
+            if offset > len(results):
124
+                results = list()
125
+            else:
126
+                if limit is not None:
127
+                    if limit + offset >= len(results):
128
+                        limit = len(results)-offset-1
129
+                    results = results[offset:offset+limit]
125
             return results
130
             return results
126
         # Default behavior
131
         # Default behavior
127
         if filters is None:
132
         if filters is None:

Loading…
Cancel
Save