(self, clause)
| 85 | return lambda obj: True |
| 86 | |
| 87 | def visit_column(self, clause): |
| 88 | try: |
| 89 | parentmapper = clause._annotations["parentmapper"] |
| 90 | except KeyError as ke: |
| 91 | raise UnevaluatableError( |
| 92 | f"Cannot evaluate column: {clause}" |
| 93 | ) from ke |
| 94 | |
| 95 | if self.target_cls and not issubclass( |
| 96 | self.target_cls, parentmapper.class_ |
| 97 | ): |
| 98 | raise UnevaluatableError( |
| 99 | "Can't evaluate criteria against " |
| 100 | f"alternate class {parentmapper.class_}" |
| 101 | ) |
| 102 | |
| 103 | parentmapper._check_configure() |
| 104 | |
| 105 | # we'd like to use "proxy_key" annotation to get the "key", however |
| 106 | # in relationship primaryjoin cases proxy_key is sometimes deannotated |
| 107 | # and sometimes apparently not present in the first place (?). |
| 108 | # While I can stop it from being deannotated (though need to see if |
| 109 | # this breaks other things), not sure right now about cases where it's |
| 110 | # not there in the first place. can fix at some later point. |
| 111 | # key = clause._annotations["proxy_key"] |
| 112 | |
| 113 | # for now, use the old way |
| 114 | try: |
| 115 | key = parentmapper._columntoproperty[clause].key |
| 116 | except orm_exc.UnmappedColumnError as err: |
| 117 | raise UnevaluatableError( |
| 118 | f"Cannot evaluate expression: {err}" |
| 119 | ) from err |
| 120 | |
| 121 | # note this used to fall back to a simple `getattr(obj, key)` evaluator |
| 122 | # if impl was None; as of #8656, we ensure mappers are configured |
| 123 | # so that impl is available |
| 124 | impl = parentmapper.class_manager[key].impl |
| 125 | |
| 126 | def get_corresponding_attr(obj): |
| 127 | if obj is None: |
| 128 | return _NO_OBJECT |
| 129 | state = inspect(obj) |
| 130 | dict_ = state.dict |
| 131 | |
| 132 | value = impl.get( |
| 133 | state, dict_, passive=PassiveFlag.PASSIVE_NO_FETCH |
| 134 | ) |
| 135 | if value is LoaderCallableStatus.PASSIVE_NO_RESULT: |
| 136 | return _EXPIRED_OBJECT |
| 137 | return value |
| 138 | |
| 139 | return get_corresponding_attr |
| 140 | |
| 141 | def visit_tuple(self, clause): |
| 142 | return self.visit_clauselist(clause) |
nothing calls this directly
no test coverage detected