Last active
April 12, 2024 15:04
-
-
Save viadanna/23e06248eda707447427c50d70d8d43b to your computer and use it in GitHub Desktop.
ALTER TABLE to make it case-sensitive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE social_auth_usersocialauth MODIFY uid VARCHAR(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL | |
""" | |
# Confirming issue | |
from social_django.models import UserSocialAuth | |
>>> UserSocialAuth.objects.select_related("user").get(provider="edx-oauth2", uid="test1") | |
<UserSocialAuth: test1> | |
>>> UserSocialAuth.objects.select_related("user").get(provider="edx-oauth2", uid="TEST1") | |
<UserSocialAuth: test1> | |
# Changing Column | |
from django.db import connection | |
cursor = connection.cursor() | |
cursor.execute("ALTER TABLE social_auth_usersocialauth MODIFY uid VARCHAR(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL") | |
5403 | |
cursor.fetchall() | |
() | |
# Testing | |
from social_django.models import UserSocialAuth | |
UserSocialAuth.objects.select_related("user").get(provider="edx-oauth2", uid="test1") | |
<UserSocialAuth: test1> | |
UserSocialAuth.objects.select_related("user").get(provider="edx-oauth2", uid="teSt1") | |
Traceback (most recent call last): | |
File "<console>", line 1, in <module> | |
File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 435, in get | |
raise self.model.DoesNotExist( | |
social_django.models.UserSocialAuth.DoesNotExist: UserSocialAuth matching query does not exist. | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment