(elem: SupportsAnnotations, **kw: Any)
| 434 | cloned_ids: Dict[int, SupportsAnnotations] = {} |
| 435 | |
| 436 | def clone(elem: SupportsAnnotations, **kw: Any) -> SupportsAnnotations: |
| 437 | # ind_cols_on_fromclause means make sure an AnnotatedFromClause |
| 438 | # has its own .c collection independent of that which its proxying. |
| 439 | # this is used specifically by orm.LoaderCriteriaOption to break |
| 440 | # a reference cycle that it's otherwise prone to building, |
| 441 | # see test_relationship_criteria-> |
| 442 | # test_loader_criteria_subquery_w_same_entity. logic here was |
| 443 | # changed for #8796 and made explicit; previously it occurred |
| 444 | # by accident |
| 445 | |
| 446 | kw["detect_subquery_cols"] = detect_subquery_cols |
| 447 | id_ = id(elem) |
| 448 | |
| 449 | if id_ in cloned_ids: |
| 450 | return cloned_ids[id_] |
| 451 | |
| 452 | if ( |
| 453 | exclude |
| 454 | and hasattr(elem, "proxy_set") |
| 455 | and elem.proxy_set.intersection(exclude) |
| 456 | ): |
| 457 | newelem = elem._clone(clone=clone, **kw) |
| 458 | elif annotations != elem._annotations: |
| 459 | if detect_subquery_cols and elem._is_immutable: |
| 460 | to_annotate = elem._clone(clone=clone, **kw) |
| 461 | else: |
| 462 | to_annotate = elem |
| 463 | if annotate_callable: |
| 464 | newelem = annotate_callable(to_annotate, annotations) |
| 465 | else: |
| 466 | newelem = _safe_annotate(to_annotate, annotations) |
| 467 | else: |
| 468 | newelem = elem |
| 469 | |
| 470 | newelem._copy_internals( |
| 471 | clone=clone, |
| 472 | ind_cols_on_fromclause=ind_cols_on_fromclause, |
| 473 | _annotations_traversal=True, |
| 474 | ) |
| 475 | |
| 476 | cloned_ids[id_] = newelem |
| 477 | return newelem |
| 478 | |
| 479 | if element is not None: |
| 480 | element = cast(_SA, clone(element)) |
no test coverage detected