(
cls,
operator: OperatorType,
continue_on: Any,
skip_on: Any,
initial_clause: Any = _NoArg.NO_ARG,
*clauses: Any,
**kw: Any,
)
| 3345 | |
| 3346 | @classmethod |
| 3347 | def _construct( |
| 3348 | cls, |
| 3349 | operator: OperatorType, |
| 3350 | continue_on: Any, |
| 3351 | skip_on: Any, |
| 3352 | initial_clause: Any = _NoArg.NO_ARG, |
| 3353 | *clauses: Any, |
| 3354 | **kw: Any, |
| 3355 | ) -> ColumnElement[Any]: |
| 3356 | if initial_clause is _NoArg.NO_ARG: |
| 3357 | # no elements period. deprecated use case. return an empty |
| 3358 | # ClauseList construct that generates nothing unless it has |
| 3359 | # elements added to it. |
| 3360 | name = operator.__name__ |
| 3361 | |
| 3362 | util.warn_deprecated( |
| 3363 | f"Invoking {name}() without arguments is deprecated, and " |
| 3364 | f"will be disallowed in a future release. For an empty " |
| 3365 | f"""{name}() construct, use '{name}({ |
| 3366 | 'true()' if continue_on is True_._singleton else 'false()' |
| 3367 | }, *args)' """ |
| 3368 | f"""or '{name}({ |
| 3369 | 'True' if continue_on is True_._singleton else 'False' |
| 3370 | }, *args)'.""", |
| 3371 | version="1.4", |
| 3372 | ) |
| 3373 | return cls._construct_raw(operator) |
| 3374 | |
| 3375 | lcc, convert_clauses = cls._process_clauses_for_boolean( |
| 3376 | operator, |
| 3377 | continue_on, |
| 3378 | skip_on, |
| 3379 | [ |
| 3380 | coercions.expect(roles.WhereHavingRole, clause) |
| 3381 | for clause in util.coerce_generator_arg( |
| 3382 | (initial_clause,) + clauses |
| 3383 | ) |
| 3384 | ], |
| 3385 | ) |
| 3386 | |
| 3387 | if lcc > 1: |
| 3388 | # multiple elements. Return regular BooleanClauseList |
| 3389 | # which will link elements against the operator. |
| 3390 | |
| 3391 | flattened_clauses = itertools.chain.from_iterable( |
| 3392 | ( |
| 3393 | (c for c in to_flat._flattened_operator_clauses) |
| 3394 | if getattr(to_flat, "operator", None) is operator |
| 3395 | else (to_flat,) |
| 3396 | ) |
| 3397 | for to_flat in convert_clauses |
| 3398 | ) |
| 3399 | |
| 3400 | return cls._construct_raw(operator, flattened_clauses) # type: ignore # noqa: E501 |
| 3401 | else: |
| 3402 | assert lcc |
| 3403 | # just one element. return it as a single boolean element, |
| 3404 | # not a list and discard the operator. |
no test coverage detected