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
Refs #20487 -- Added test for querying mixed case fields with common related model. #9594
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some notes about making the test a little more readable, but generally LGTM.
tests/queries/models.py
Outdated
@@ -449,6 +449,10 @@ def __str__(self): | |||
return "category item: " + str(self.category) | |||
|
|||
|
|||
class MixedCaseCategoryItem(models.Model): | |||
Category = models.ForeignKey('SimpleCategory', models.CASCADE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment to draw attention to the capital C, or maybe even change the name to something like CaTeGoRy
. It's quite easy to miss it as it stands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either that or leave the attribute name alone and define a db_column='CaTeGoRy'
to put more emphasis on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think the test with db_column='CaTeGoRy'
is a slightly different test, and one we may want to include as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's a different case. I added it.
@@ -1172,6 +1173,17 @@ def test_lookup_constraint_fielderror(self): | |||
with self.assertRaisesMessage(FieldError, msg): | |||
Tag.objects.filter(unknown_field__name='generic') | |||
|
|||
def test_common_mixed_case_foreign_keys(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add a docstring along the lines of "verify that a valid query is generated when fields fetched from joined tables include FKs whose names only differ by case"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The coding guidelines suggest to omit prefixes like "Verify that" since all tests verify things, otherwise the patch looks fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I updated the docstring,
8ea2f0a
to
5fb5781
Compare
@shaib @charettes Thanks for reviews. I updated PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for taking care of this!
…related model. Thanks Shai Berger for the review.
https://code.djangoproject.com/ticket/20487