Skip to content

Conversation

@qasimgulzar
Copy link
Contributor

@qasimgulzar qasimgulzar commented Nov 18, 2024

Summary

This pull request includes updates to the StringAgg class in openedx_tagging/core/tagging/models/utils.py to 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 the Combinable class.

Enhancements to StringAgg class:

  • Added support for PostgreSQL by using STRING_AGG with a specified separator and ensuring expressions are cast to TEXT.
  • Added support for MySQL and SQLite by using GROUP_CONCAT with a specified separator.
  • Implemented abstract methods from the Combinable class to allow logical operations (AND, OR, XOR).

Additional changes:

  • Imported db_connection from django.db to check the database backend.
  • Updated the StringAgg class to accept a delimiter parameter and handle the distinct option and output type accordingly.

This PR is subsequent of openedx/edx-platform#35762

@openedx-webhooks
Copy link

openedx-webhooks commented Nov 18, 2024

Thanks for the pull request, @qasimgulzar!

This repository is currently maintained by @axim-engineering.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Nov 18, 2024
@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Nov 21, 2024
@mphilbrick211
Copy link

Hi @qasimgulzar! Just flagging some failing checks for you.

@mphilbrick211 mphilbrick211 removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Dec 9, 2024
@qasimgulzar
Copy link
Contributor Author

Thank you I will be looking into it.

@qasimgulzar
Copy link
Contributor Author

@mphilbrick211 please approve the actions

@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Dec 12, 2024
@qasimgulzar
Copy link
Contributor Author

I am going to take care of these broken tests

@mphilbrick211 mphilbrick211 removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Jan 15, 2025
@mphilbrick211
Copy link

Hi @qasimgulzar! Just flagging there's a couple failing checks here.

@qasimgulzar
Copy link
Contributor Author

It is on my radar for this week.

@qasimgulzar
Copy link
Contributor Author

@mphilbrick211 could you please approve the workflows

@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Mar 6, 2025
@mphilbrick211 mphilbrick211 moved this from Waiting on Author to Needs Tests Run or CLA Signed in Contributions Mar 6, 2025
@mphilbrick211
Copy link

All set, @qasimgulzar!

@mphilbrick211 mphilbrick211 removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Mar 6, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Tests Run or CLA Signed to Waiting on Author in Contributions Mar 6, 2025
@mphilbrick211 mphilbrick211 moved this from Waiting on Author to Ready for Review in Contributions Mar 12, 2025
@mphilbrick211
Copy link

@openedx/axim-engineering - this is ready for review. Thanks!

Copy link
Contributor

@ormsbee ormsbee left a 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?

Copy link
Contributor

@pomegranited pomegranited left a 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})
Copy link
Contributor

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?

Suggested change
extra.update({"delimiter": delimiter})
extra.update({"delimiter": ","})

Copy link
Contributor

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?

Suggested change
extra.update({"delimiter": delimiter})
extra.update({
"delimiter": ",",
"output_field": TextField(),
})

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor

@pomegranited pomegranited left a 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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
';', # 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@mphilbrick211 mphilbrick211 moved this from Ready for Review to Ready to Merge in Contributions May 12, 2025
@mphilbrick211
Copy link

@ormsbee are you able to merge this if it's all set?

@Lord-KalEl
Copy link

🎉

@qasimgulzar
Copy link
Contributor Author

@ormsbee @mphilbrick211 could you please merge this PR?

@mphilbrick211 mphilbrick211 requested a review from ormsbee July 16, 2025 18:51
@mphilbrick211
Copy link

Bumping for when @ormsbee is back from vacation.

@qasimgulzar
Copy link
Contributor Author

@ormsbee can we merge this one, I need to push for edx-platform after this one

@Lord-KalEl
Copy link

Hi, I'm glad to read this … but 1 question to this process:
How can I see, which release version it is? I use podman compose to deploy applications, but in this case, I dont find any version, release or something else …

I hope, it is not too offtopic …I'm sorry …

@ormsbee
Copy link
Contributor

ormsbee commented Aug 21, 2025

@bradenmacdonald: Do you consider your review to be blocking?

Copy link
Contributor

@bradenmacdonald bradenmacdonald left a 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": ",",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"delimiter": ",",
"delimiter": delimiter,

Isn't this all that's needed to address my comment?

@qasimgulzar
Copy link
Contributor Author

@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.

@bradenmacdonald I can update function to use delimiter parameter instead of hardcoding it, if that resolves your concerns.

@bradenmacdonald
Copy link
Contributor

@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.

@qasimgulzar
Copy link
Contributor Author

@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.

@bradenmacdonald
Copy link
Contributor

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.

@ormsbee ormsbee merged commit a241755 into openedx:main Sep 4, 2025
11 checks passed
@github-project-automation github-project-automation bot moved this from Ready to Merge to Done in Contributions Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants