Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing stub for 'Query.join()' #1404

Merged
merged 3 commits into from Mar 20, 2023

Conversation

RyanWalker277
Copy link
Contributor

Related issues

Fixes #1402

Code changes

Added a stub for the join method with the proper type annotations. The join method takes in a string for the table parameter and a tuple of two strings for the on parameter, which represents the columns from each table that should be joined. Hope it clears things up!

@@ -197,6 +197,7 @@ class Query(BaseExpression):
def check_filterable(self, expression: Any) -> None: ...
def build_lookup(self, lookups: Sequence[str], lhs: Expression | Query, rhs: Any) -> Lookup: ...
def try_transform(self, lhs: Expression | Query, name: str) -> Transform: ...
def join(self, join: str, reuse: str | None = ..., reuse_with_filtered_relation: bool = ...) -> str: ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the confusion. I'll update it accordingly. Thanks for pointing it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is described here: https://github.com/django/django/blob/e10c1688f96e3b2d202fe401472b7b25f6105969/django/db/models/sql/query.py#L995-L997

According to the description, 'join' is either a base_table_class or join_class. I think Type[BaseTable | Join] would be the correct type argument in this case. Let me know your thoughts on this one. I am making a commit to test the change on the CI as pytest is giving some unexpected results at my end.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@sobolevn sobolevn merged commit ddf0864 into typeddjango:master Mar 20, 2023
14 checks passed
@RyanWalker277 RyanWalker277 deleted the Fix#1402 branch March 20, 2023 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Query.join() is missing from the stubs
2 participants