Applies a order_by clause :param str attribute: attribute to apply on :param bool ascending: should it apply ascending order or descending :rtype: Query
(self, attribute=None, *, ascending=True)
| 1240 | |
| 1241 | @fluent |
| 1242 | def order_by(self, attribute=None, *, ascending=True): |
| 1243 | """ Applies a order_by clause |
| 1244 | |
| 1245 | :param str attribute: attribute to apply on |
| 1246 | :param bool ascending: should it apply ascending order or descending |
| 1247 | :rtype: Query |
| 1248 | """ |
| 1249 | attribute = self._get_mapping(attribute) or self._attribute |
| 1250 | if attribute: |
| 1251 | self._order_by[attribute] = None if ascending else 'desc' |
| 1252 | else: |
| 1253 | raise ValueError( |
| 1254 | 'Attribute property needed. call on_attribute(attribute) ' |
| 1255 | 'or new(attribute)') |
| 1256 | return self |
| 1257 | |
| 1258 | def open_group(self): |
| 1259 | """ Applies a precedence grouping in the next filters """ |
nothing calls this directly
no test coverage detected