MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / OrderByList

Class OrderByList

lib/sqlalchemy/sql/elements.py:2937–3002  ·  view source on GitHub ↗

Describe a list of clauses that will be comma separated to nest within an ORDER BY. .. versionadded:: 2.1

Source from the content-addressed store, hash-verified

2935
2936
2937class OrderByList(
2938 roles.OrderByRole,
2939 operators.OrderingOperators,
2940 DQLDMLClauseElement,
2941):
2942 """Describe a list of clauses that will be comma separated to nest
2943 within an ORDER BY.
2944
2945 .. versionadded:: 2.1
2946
2947 """
2948
2949 __visit_name__ = "order_by_list"
2950
2951 _traverse_internals: _TraverseInternalsType = [
2952 ("clauses", InternalTraversal.dp_clauseelement_tuple),
2953 ]
2954
2955 clauses: List[ColumnElement[Any]]
2956
2957 def __init__(
2958 self,
2959 clauses: Iterable[Union[OrderByList, _ColumnExpressionArgument[Any]]],
2960 ):
2961 text_converter_role: Type[roles.SQLRole] = roles.ByOfRole
2962 self._text_converter_role = text_converter_role
2963
2964 self.clauses = [
2965 coercions.expect(
2966 text_converter_role, clause, apply_propagate_attrs=self
2967 )
2968 for clause in clauses
2969 ]
2970
2971 def __iter__(self) -> Iterator[ColumnElement[Any]]:
2972 return iter(self.clauses)
2973
2974 def __len__(self) -> int:
2975 return len(self.clauses)
2976
2977 @property
2978 def _select_iterable(self) -> _SelectIterable:
2979 return itertools.chain.from_iterable(
2980 [elem._select_iterable for elem in self.clauses]
2981 )
2982
2983 @util.ro_non_memoized_property
2984 def _from_objects(self) -> List[FromClause]:
2985 return list(itertools.chain(*[c._from_objects for c in self.clauses]))
2986
2987 def self_group(
2988 self, against: Optional[OperatorType] = None
2989 ) -> Union[Self, Grouping[Any]]:
2990 return self
2991
2992 def desc(self) -> OrderByList:
2993 return OrderByList([e.desc() for e in self.clauses])
2994

Callers 8

test_order_by_listMethod · 0.90
CoreFixturesClass · 0.90
descMethod · 0.90
descMethod · 0.85
ascMethod · 0.85
nulls_firstMethod · 0.85
nulls_lastMethod · 0.85

Calls

no outgoing calls

Tested by 3

test_order_by_listMethod · 0.72
descMethod · 0.72