LocalDataQuerySet order_by implementation
Review Request #7200 — Created April 14, 2015 and submitted
Queries or calls may want items in a LocalDataQuerySet to be ordered for usage. To help bridge the gap between LocalDataQuerySet and a Django queryset, an
order_by
function has been created to order items in the LocalDataQuerySet by the specified attributes, similar to Django queryset.
Test case for
order_by
.
Description | From | Last Updated |
---|---|---|
This should probably be a member of the LocalDataQuerySet class. The _COMPILED bit is unnecessary. |
brennie | |
Can we use ascending and descending here (instead of non-descending and non-ascending) ? |
brennie | |
This doesn't need a leading underscore. It won't be visible outside this function. |
brennie | |
Can this be written to use iteration instead of recursion? |
brennie | |
I think this should probably clone the data and sort that instead, e.g. copy = self.clone() copy._data.sort(...) return copy |
brennie | |
Col: 57 E231 missing whitespace after ',' |
reviewbot | |
Col: 59 E231 missing whitespace after ',' |
reviewbot | |
Function names should be verb phrases. How about compare ? |
brennie | |
The first line of a docstring should be written in the imperative mood. How about "Compare two elements of the … |
brennie | |
Since you are using attrs[i] and i, you can change this to use enumerate(attrs). |
brennie | |
Blank line between these. |
brennie | |
Blank line after class docstring. |
brennie |
- Change Summary:
-
Removed the trailing comma in the arrays for
test_order_by
. - Commit:
-
ae7c7254124ea17f423396311a09888da307c84d22e0de64e9736f0e562830b8a16ba1d4c06489e6
-
Tool: PEP8 Style Checker Processed Files: djblets/db/query.py djblets/db/tests/test_local_data_query_set.py Tool: Pyflakes Processed Files: djblets/db/query.py djblets/db/tests/test_local_data_query_set.py
- Change Summary:
-
Changed recursive call to be iterative instead.
Moved global variable as a member of a class instead.
Updated the description to be ascending and descending instead of the "non" versions.
Removed leading underscore for function naming.
Changed xrange to range for Python3 compatability.
- Commit:
-
22e0de64e9736f0e562830b8a16ba1d4c06489e6918875da7af0c87bbd41d93b2ce353cd9cf735e8
-
Tool: PEP8 Style Checker Processed Files: djblets/db/query.py djblets/db/tests/test_local_data_query_set.py Tool: Pyflakes Processed Files: djblets/db/query.py djblets/db/tests/test_local_data_query_set.py
- Change Summary:
-
Updated to documentation and naming of the comparator function.
Used iterator for attributes instead of indexing the attributes.
- Commit:
-
918875da7af0c87bbd41d93b2ce353cd9cf735e8dc6cb069888c3964b9ea0d77bf33defc845d0aad
-
Tool: Pyflakes Processed Files: djblets/db/query.py djblets/db/tests/test_local_data_query_set.py Tool: PEP8 Style Checker Processed Files: djblets/db/query.py djblets/db/tests/test_local_data_query_set.py
- Change Summary:
-
Added blank line and removed the
start
(default is already 0) argument for range in the test cases. - Commit:
-
dc6cb069888c3964b9ea0d77bf33defc845d0aadc895f39c37e3de8b4d5292fc5ef189769f7cad38