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

Refs #20487 -- Added test for querying mixed case fields with common related model. #9594

Merged
merged 1 commit into from Jan 20, 2018

Conversation

felixxm
Copy link
Member

@felixxm felixxm commented Jan 17, 2018

Copy link
Member

@shaib shaib left a 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.

@@ -449,6 +449,10 @@ def __str__(self):
return "category item: " + str(self.category)


class MixedCaseCategoryItem(models.Model):
Category = models.ForeignKey('SimpleCategory', models.CASCADE)
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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):
Copy link
Member

@shaib shaib Jan 17, 2018

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"

Copy link
Member

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.

Copy link
Member Author

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,

@felixxm felixxm force-pushed the refs-20487 branch 2 times, most recently from 8ea2f0a to 5fb5781 Compare January 18, 2018 08:01
@felixxm
Copy link
Member Author

felixxm commented Jan 18, 2018

@shaib @charettes Thanks for reviews. I updated PR.

Copy link
Member

@shaib shaib left a 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.
@felixxm felixxm merged commit aad1833 into django:master Jan 20, 2018
@felixxm felixxm deleted the refs-20487 branch January 20, 2018 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants