(path, attrname, parent_entity)
| 2539 | |
| 2540 | |
| 2541 | def _raise_for_does_not_link(path, attrname, parent_entity): |
| 2542 | if len(path) > 1: |
| 2543 | path_is_of_type = path[-1].entity is not path[-2].mapper.class_ |
| 2544 | if insp_is_aliased_class(parent_entity): |
| 2545 | parent_entity_str = str(parent_entity) |
| 2546 | else: |
| 2547 | parent_entity_str = parent_entity.class_.__name__ |
| 2548 | |
| 2549 | raise sa_exc.ArgumentError( |
| 2550 | f'ORM mapped entity or attribute "{attrname}" does not ' |
| 2551 | f'link from relationship "{path[-2]}%s".%s' |
| 2552 | % ( |
| 2553 | f".of_type({path[-1]})" if path_is_of_type else "", |
| 2554 | ( |
| 2555 | " Did you mean to use " |
| 2556 | f'"{path[-2]}' |
| 2557 | f'.of_type({parent_entity_str})" or "loadopt.options(' |
| 2558 | f"selectin_polymorphic({path[-2].mapper.class_.__name__}, " |
| 2559 | f'[{parent_entity_str}]), ...)" ?' |
| 2560 | if not path_is_of_type |
| 2561 | and not path[-1].is_aliased_class |
| 2562 | and orm_util._entity_corresponds_to( |
| 2563 | path.entity, inspect(parent_entity).mapper |
| 2564 | ) |
| 2565 | else "" |
| 2566 | ), |
| 2567 | ) |
| 2568 | ) |
| 2569 | else: |
| 2570 | raise sa_exc.ArgumentError( |
| 2571 | f'ORM mapped attribute "{attrname}" does not ' |
| 2572 | f'link mapped class "{path[-1]}"' |
| 2573 | ) |
no test coverage detected