(
cls,
operator: OperatorType,
continue_on: Any,
skip_on: Any,
initial_clause: Any = _NoArg.NO_ARG,
*clauses: Any,
**kw: Any,
)
| 3062 | |
| 3063 | @classmethod |
| 3064 | def _construct( |
| 3065 | cls, |
| 3066 | operator: OperatorType, |
| 3067 | continue_on: Any, |
| 3068 | skip_on: Any, |
| 3069 | initial_clause: Any = _NoArg.NO_ARG, |
| 3070 | *clauses: Any, |
| 3071 | **kw: Any, |
| 3072 | ) -> ColumnElement[Any]: |
| 3073 | if initial_clause is _NoArg.NO_ARG: |
| 3074 | # no elements period. deprecated use case. return an empty |
| 3075 | # ClauseList construct that generates nothing unless it has |
| 3076 | # elements added to it. |
| 3077 | name = operator.__name__ |
| 3078 | |
| 3079 | util.warn_deprecated( |
| 3080 | f"Invoking {name}() without arguments is deprecated, and " |
| 3081 | f"will be disallowed in a future release. For an empty " |
| 3082 | f"""{name}() construct, use '{name}({ |
| 3083 | 'true()' if continue_on is True_._singleton else 'false()' |
| 3084 | }, *args)' """ |
| 3085 | f"""or '{name}({ |
| 3086 | 'True' if continue_on is True_._singleton else 'False' |
| 3087 | }, *args)'.""", |
| 3088 | version="1.4", |
| 3089 | ) |
| 3090 | return cls._construct_raw(operator) |
| 3091 | |
| 3092 | lcc, convert_clauses = cls._process_clauses_for_boolean( |
| 3093 | operator, |
| 3094 | continue_on, |
| 3095 | skip_on, |
| 3096 | [ |
| 3097 | coercions.expect(roles.WhereHavingRole, clause) |
| 3098 | for clause in util.coerce_generator_arg( |
| 3099 | (initial_clause,) + clauses |
| 3100 | ) |
| 3101 | ], |
| 3102 | ) |
| 3103 | |
| 3104 | if lcc > 1: |
| 3105 | # multiple elements. Return regular BooleanClauseList |
| 3106 | # which will link elements against the operator. |
| 3107 | |
| 3108 | flattened_clauses = itertools.chain.from_iterable( |
| 3109 | ( |
| 3110 | (c for c in to_flat._flattened_operator_clauses) |
| 3111 | if getattr(to_flat, "operator", None) is operator |
| 3112 | else (to_flat,) |
| 3113 | ) |
| 3114 | for to_flat in convert_clauses |
| 3115 | ) |
| 3116 | |
| 3117 | return cls._construct_raw(operator, flattened_clauses) # type: ignore # noqa: E501 |
| 3118 | else: |
| 3119 | assert lcc |
| 3120 | # just one element. return it as a single boolean element, |
| 3121 | # not a list and discard the operator. |
no test coverage detected