MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / FrameClause

Class FrameClause

lib/sqlalchemy/sql/elements.py:4632–4752  ·  view source on GitHub ↗

Indicate the 'rows' 'range' or 'group' field of a window function, e.g. using :class:`.Over`. .. versionadded:: 2.1

Source from the content-addressed store, hash-verified

4630
4631
4632class FrameClause(ClauseElement):
4633 """Indicate the 'rows' 'range' or 'group' field of a window function,
4634 e.g. using :class:`.Over`.
4635
4636 .. versionadded:: 2.1
4637
4638 """
4639
4640 __visit_name__ = "frame_clause"
4641
4642 _traverse_internals: _TraverseInternalsType = [
4643 ("lower_bind", InternalTraversal.dp_clauseelement),
4644 ("upper_bind", InternalTraversal.dp_clauseelement),
4645 ("lower_type", InternalTraversal.dp_plain_obj),
4646 ("upper_type", InternalTraversal.dp_plain_obj),
4647 ]
4648
4649 def __init__(
4650 self,
4651 start: Any,
4652 end: Any,
4653 start_frame_type: FrameClauseType,
4654 end_frame_type: FrameClauseType,
4655 _validate: bool = True,
4656 ) -> None:
4657 """Creates a new FrameClause specifying the bounds of a window frame.
4658
4659 :param start: The start value.
4660 :param end: The end value.
4661 :param start_frame_type: The :class:`FrameClauseType` for the
4662 start value.
4663 :param end_frame_type: The :class:`FrameClauseType` for the end value.
4664 """
4665 self.lower_bind = self._as_literal(start)
4666 self.upper_bind = self._as_literal(end)
4667 self.lower_type = FrameClauseType(start_frame_type)
4668 self.upper_type = FrameClauseType(end_frame_type)
4669 if _validate:
4670 if (
4671 self.lower_type in _require_none
4672 and self.lower_bind is not None
4673 ):
4674 raise exc.ArgumentError(
4675 "Cannot specify a value for start with frame type "
4676 f"{self.lower_type.name}"
4677 )
4678 if (
4679 self.upper_type in _require_none
4680 and self.upper_bind is not None
4681 ):
4682 raise exc.ArgumentError(
4683 "Cannot specify a value for end with frame type "
4684 f"{self.upper_type.name}"
4685 )
4686
4687 @classmethod
4688 def _as_literal(cls, value: Any) -> BindParameter[Any] | None:
4689 if value is None:

Callers 7

test_over_framespecMethod · 0.90
CoreFixturesClass · 0.90
_parseMethod · 0.85

Calls

no outgoing calls