An object that contains a reference to an outer query. In this case, the reference to the outer query has been resolved because the inner query has been used as a subquery.
| 944 | |
| 945 | |
| 946 | class ResolvedOuterRef(F): |
| 947 | """ |
| 948 | An object that contains a reference to an outer query. |
| 949 | |
| 950 | In this case, the reference to the outer query has been resolved because |
| 951 | the inner query has been used as a subquery. |
| 952 | """ |
| 953 | |
| 954 | contains_aggregate = False |
| 955 | contains_over_clause = False |
| 956 | |
| 957 | def as_sql(self, *args, **kwargs): |
| 958 | raise ValueError( |
| 959 | "This queryset contains a reference to an outer query and may " |
| 960 | "only be used in a subquery." |
| 961 | ) |
| 962 | |
| 963 | def resolve_expression(self, *args, **kwargs): |
| 964 | col = super().resolve_expression(*args, **kwargs) |
| 965 | if col.contains_over_clause: |
| 966 | raise NotSupportedError( |
| 967 | f"Referencing outer query window expression is not supported: " |
| 968 | f"{self.name}." |
| 969 | ) |
| 970 | # FIXME: Rename possibly_multivalued to multivalued and fix detection |
| 971 | # for non-multivalued JOINs (e.g. foreign key fields). This should take |
| 972 | # into account only many-to-many and one-to-many relationships. |
| 973 | col.possibly_multivalued = LOOKUP_SEP in self.name |
| 974 | return col |
| 975 | |
| 976 | def relabeled_clone(self, relabels): |
| 977 | return self |
| 978 | |
| 979 | def get_group_by_cols(self): |
| 980 | return [] |
| 981 | |
| 982 | |
| 983 | class OuterRef(F): |
no outgoing calls
no test coverage detected