MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / ClauseList

Class ClauseList

lib/sqlalchemy/sql/elements.py:2722–2827  ·  view source on GitHub ↗

Describe a list of clauses, separated by an operator. By default, is comma-separated, such as a column listing.

Source from the content-addressed store, hash-verified

2720
2721
2722class ClauseList(
2723 roles.InElementRole,
2724 roles.OrderByRole,
2725 roles.ColumnsClauseRole,
2726 roles.DMLColumnRole,
2727 DQLDMLClauseElement,
2728):
2729 """Describe a list of clauses, separated by an operator.
2730
2731 By default, is comma-separated, such as a column listing.
2732
2733 """
2734
2735 __visit_name__ = "clauselist"
2736
2737 # this is used only by the ORM in a legacy use case for
2738 # composite attributes
2739 _is_clause_list = True
2740
2741 _traverse_internals: _TraverseInternalsType = [
2742 ("clauses", InternalTraversal.dp_clauseelement_list),
2743 ("operator", InternalTraversal.dp_operator),
2744 ]
2745
2746 clauses: List[ColumnElement[Any]]
2747
2748 def __init__(
2749 self,
2750 *clauses: _ColumnExpressionArgument[Any],
2751 operator: OperatorType = operators.comma_op,
2752 group: bool = True,
2753 group_contents: bool = True,
2754 _literal_as_text_role: Type[roles.SQLRole] = roles.WhereHavingRole,
2755 ):
2756 self.operator = operator
2757 self.group = group
2758 self.group_contents = group_contents
2759 clauses_iterator: Iterable[_ColumnExpressionArgument[Any]] = clauses
2760 text_converter_role: Type[roles.SQLRole] = _literal_as_text_role
2761 self._text_converter_role = text_converter_role
2762
2763 if self.group_contents:
2764 self.clauses = [
2765 coercions.expect(
2766 text_converter_role, clause, apply_propagate_attrs=self
2767 ).self_group(against=self.operator)
2768 for clause in clauses_iterator
2769 ]
2770 else:
2771 self.clauses = [
2772 coercions.expect(
2773 text_converter_role, clause, apply_propagate_attrs=self
2774 )
2775 for clause in clauses_iterator
2776 ]
2777 self._is_implicitly_boolean = operators.is_boolean(self.operator)
2778
2779 @classmethod

Calls

no outgoing calls