-
Notifications
You must be signed in to change notification settings - Fork 14
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
Trim whitespace of existing assignment and grouping titles #6477
Conversation
def upgrade() -> None: | ||
conn = op.get_bind() | ||
|
||
result = conn.execute( |
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.
) | ||
print(f"Assignment titles updated: {result.rowcount}") | ||
|
||
result = conn.execute( |
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.
) | ||
print(f"Empty assignment titles: {result.rowcount}") | ||
|
||
result = conn.execute( |
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.
For #6456 |
Could you add a description to the PR? |
My bad, had to many PRs and marked the wrong one ready for review. Added a bit more context now. |
sa.text( | ||
""" | ||
UPDATE assignment SET title = TRIM(title) | ||
WHERE TRIM(title) != title; |
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.
Does this really make a difference? Couldn't we just get away with UPDATE assignment SET title = TRIM(title)
?
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, while the where makes the query slower it should lock less rows which should be safer
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.
Ah, good point.
Since #6472 we do the same in the python code, we trim new assignment and course titles. We also normalize empty (``) titles to null.
This PR does the same for existing titles in the DB with a DB migration.
Testing