-
Notifications
You must be signed in to change notification settings - Fork 17
fix: make database function compatible with postgresql and mysql both #260
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
Conversation
|
Thanks for the pull request, @qasimgulzar! 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. |
|
Hi @qasimgulzar! Just flagging some failing checks for you. |
|
Thank you I will be looking into it. |
|
@mphilbrick211 please approve the actions |
|
I am going to take care of these broken tests |
|
Hi @qasimgulzar! Just flagging there's a couple failing checks here. |
|
It is on my radar for this week. |
|
@mphilbrick211 could you please approve the workflows |
|
All set, @qasimgulzar! |
|
@openedx/axim-engineering - this is ready for review. Thanks! |
ormsbee
left a comment
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.
@pomegranited, @navinkarkera, @bradenmacdonald: Do any of you folks want to take a look at this before I merge?
pomegranited
left a comment
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'm not going to block merging this, so please consider my comments as suggestions :)
| if 'postgresql' in db_connection.vendor.lower(): | ||
| self.function = 'STRING_AGG' | ||
| self.template = '%(function)s(%(distinct)s%(expressions)s, %(delimiter)s)' | ||
| extra.update({"delimiter": delimiter}) |
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.
If delimiter cannot be customized for MySQL or SQLite, then I don't think it should be exposed as an argument to the constructor here.
Can we just hardcode it to ',' for postgres?
| extra.update({"delimiter": delimiter}) | |
| extra.update({"delimiter": ","}) |
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.
And is it possible to avoid overriding as_sql() below by providing the same output_field that postgres StringAgg does?
| extra.update({"delimiter": delimiter}) | |
| extra.update({ | |
| "delimiter": ",", | |
| "output_field": TextField(), | |
| }) |
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 think that's a great idea
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.
@pomegranited I just updated the PR as per your recommendations, thank you for the great suggestion
pomegranited
left a comment
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.
👍 Oh good, I'm glad my suggestions were helpful @qasimgulzar . Thank you for doing this, and all the other parts of this massive effort!
- I tested this with MySQL under my usual devstack (not with Postgres or SQLite)
- I read through the code
- Includes documentation
| ' > ', # Used in the search index and Instantsearch frontend to separate tag levels | ||
| # e.g. tags_level3="Earth > North America > Mexico > Mexico City" | ||
| ';', # Used in CSV exports to separate multiple tags from the same taxonomy | ||
| ';', # Used in CSV exports to separate multiple tags from the same taxonomy… |
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.
| ';', # Used in CSV exports to separate multiple tags from the same taxonomy… | |
| ';', # Used in CSV exports to separate multiple tags from the same taxonomy |
Not sure why this ellipsis character was added here.
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.
Updated
|
@ormsbee are you able to merge this if it's all set? |
|
🎉 |
|
@ormsbee @mphilbrick211 could you please merge this PR? |
|
Bumping for when @ormsbee is back from vacation. |
|
@ormsbee can we merge this one, I need to push for edx-platform after this one |
|
Hi, I'm glad to read this … but 1 question to this process: I hope, it is not too offtopic …I'm sorry … |
|
@bradenmacdonald: Do you consider your review to be blocking? |
bradenmacdonald
left a comment
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.
@ormsbee I don't think we should merge a function that accepts a delimiter parameter but doesn't use it, and instead always hard-codes ,. But I could be missing something about how that is used. So I would like to see that changed or a comment added to explain before this merges. Otherwise no blockers.
| self.function = 'STRING_AGG' | ||
| self.template = '%(function)s(%(distinct)s%(expressions)s, %(delimiter)s)' | ||
| extra.update({ | ||
| "delimiter": ",", |
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.
| "delimiter": ",", | |
| "delimiter": delimiter, |
Isn't this all that's needed to address my comment?
@bradenmacdonald I can update function to use delimiter parameter instead of hardcoding it, if that resolves your concerns. |
|
@qasimgulzar Yes that would resolve my concerns. Or remove the parameter, since we didn't have it before - I believe you added it but it's unused as far as I can tell. |
@bradenmacdonald I have updated the PR to use delimiter param to make it configurable. |
|
Thanks @qasimgulzar. That resolves my concern. @ormsbee This can move ahead as long as someone else has reviewed/approved it - I don't have any concerns remaining nor plan to review any further. |
Summary
This pull request includes updates to the
StringAggclass inopenedx_tagging/core/tagging/models/utils.pyto enhance its functionality and compatibility with different database backends. The most important changes include adding support for PostgreSQL, MySQL, and SQLite, and implementing abstract methods from theCombinableclass.Enhancements to
StringAggclass:STRING_AGGwith a specified separator and ensuring expressions are cast toTEXT.GROUP_CONCATwith a specified separator.Combinableclass to allow logical operations (AND,OR,XOR).Additional changes:
db_connectionfromdjango.dbto check the database backend.StringAggclass to accept adelimiterparameter and handle thedistinctoption and output type accordingly.This PR is subsequent of openedx/edx-platform#35762