feat: CourseKeyField can now be optionally case-sensitive, has default max_length [FC-0117]#426
Conversation
|
Thanks for the pull request, @bradenmacdonald! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
1 similar comment
|
Thanks for the pull request, @bradenmacdonald! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
b8eb2a1 to
ddfc905
Compare
ddfc905 to
b180195
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #426 +/- ##
==========================================
+ Coverage 93.93% 94.13% +0.19%
==========================================
Files 31 31
Lines 3036 3068 +32
Branches 191 191
==========================================
+ Hits 2852 2888 +36
+ Misses 157 155 -2
+ Partials 27 25 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
kdmccormick
left a comment
There was a problem hiding this comment.
Thanks for this, I think it's a great improvement. I didn't see any issues other than my postgres comment. I would want @ormsbee to take a look at this before merging, though.
| """ | ||
| Return database parameters for this field. This adds collation info, to | ||
| make the key field case-sensitive (optionally). | ||
|
|
There was a problem hiding this comment.
I keep seeing PRs about adding/fixing postgres support to the platform, so I wonder if it's worth making the case-insensitivity work on postgres too. At the very least, could you add your postgres note from the PR description here?
There was a problem hiding this comment.
From my research, getting case-insensitivity to work on PostgreSQL is not possible without a migration to create a case-insensitive collation (once, for the whole database), which we could then use. Since this library has no migrations, I don't think we should do that.
I can definitely add the note here though.
|
I have a PR here to validate this before merging, but it's held up by some docker rate limit issues. |
|
OK, the validation PR caught another test where the tests were passing on SQLite but would have failed on MySQL due to different sorting of course IDs ( So I think that's a good sign. Otherwise, I don't see any signs of unexpected side effects, so I think this PR is good to merge. |
kdmccormick
left a comment
There was a problem hiding this comment.
Could you add that note about postgres to the code? With that added, merge away 🚀
|
@kdmccormick I did already? 293058a |
|
Ah, sorry, I was looking for the comment in the db_params docstring, I didn't look closely enough at your commits. LGTM. |
Our
CourseKeyFieldand other opaque key fields by default are case-sensitive on SQLite but case-insensitive on MySQL. This opposite behavior can result in surprising bugs if you only test on SQLite.This PR:
CourseKeyFieldso that it's case-insensitive by default on both SQLite and MySQL, matching the previous MySQL default behaviorblankormax_length? e.g. if your database was still usingutf8_general_ciby default and you make some unrelated change that results in anALTER TABLEmigration that updates one of these columns, it may change the collation toutf8mb4_unicode_ci. Since opaque keys are restricted to mostly ASCII characters anyways, I don't think this will matter, if it even happens. (?)CourseKeyField(case_sensitive=True), which is highly recommended, and will apply to both SQLite and MySQL consistently.max_lengthso you don't have to pointlessly specify the same max length over and over every time you store an opaque key field.case_sensitive=Trueargument will be ignored. But I think that PostgreSQL will always be case sensitive by default, and doesn't ship with any case-insensitive collations, although you can manually create them. (ref)