-
Notifications
You must be signed in to change notification settings - Fork 963
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct normalization of Dynamic field names (#16122)
This led to the incorrect string being sent to the DB for the Dynamic ENUM when it was any of the following: `Home-Page`, `Download-Url`, `Author-Email`, `Maintainer-Email`, or `Project-Url`. This PR sets the strings in the Enum to be all `title()`ified and renames any existing values.
- Loading branch information
Showing
2 changed files
with
119 additions
and
5 deletions.
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
warehouse/migrations/versions/b14df478c48f_correct_dynamic_field_normalization.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
""" | ||
Correct Dynamic Field Normalization | ||
Revision ID: b14df478c48f | ||
Revises: cec0316503a5 | ||
Create Date: 2024-06-17 14:20:18.254557 | ||
""" | ||
|
||
from alembic import op | ||
from alembic_postgresql_enum import ColumnType, TableReference | ||
|
||
revision = "b14df478c48f" | ||
down_revision = "cec0316503a5" | ||
|
||
|
||
def upgrade(): | ||
op.sync_enum_values( | ||
"public", | ||
"release_dynamic_fields", | ||
[ | ||
"Platform", | ||
"Supported-Platform", | ||
"Summary", | ||
"Description", | ||
"Description-Content-Type", | ||
"Keywords", | ||
"Home-Page", | ||
"Download-Url", | ||
"Author", | ||
"Author-Email", | ||
"Maintainer", | ||
"Maintainer-Email", | ||
"License", | ||
"Classifier", | ||
"Requires-Dist", | ||
"Requires-Python", | ||
"Requires-External", | ||
"Project-Url", | ||
"Provides-Extra", | ||
"Provides-Dist", | ||
"Obsoletes-Dist", | ||
], | ||
[ | ||
TableReference( | ||
table_schema="public", | ||
table_name="releases", | ||
column_name="dynamic", | ||
column_type=ColumnType.ARRAY, | ||
) | ||
], | ||
enum_values_to_rename=[ | ||
("Home-page", "Home-Page"), | ||
("Download-URL", "Download-Url"), | ||
("Author-email", "Author-Email"), | ||
("Maintainer-email", "Maintainer-Email"), | ||
("Project-URL", "Project-Url"), | ||
], | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.sync_enum_values( | ||
"public", | ||
"release_dynamic_fields", | ||
[ | ||
"Platform", | ||
"Supported-Platform", | ||
"Summary", | ||
"Description", | ||
"Description-Content-Type", | ||
"Keywords", | ||
"Home-page", | ||
"Download-URL", | ||
"Author", | ||
"Author-email", | ||
"Maintainer", | ||
"Maintainer-email", | ||
"License", | ||
"Classifier", | ||
"Requires-Dist", | ||
"Requires-Python", | ||
"Requires-External", | ||
"Project-URL", | ||
"Provides-Extra", | ||
"Provides-Dist", | ||
"Obsoletes-Dist", | ||
], | ||
[ | ||
TableReference( | ||
table_schema="public", | ||
table_name="releases", | ||
column_name="dynamic", | ||
column_type=ColumnType.ARRAY, | ||
) | ||
], | ||
enum_values_to_rename=[ | ||
("Home-Page", "Home-page"), | ||
("Download-Url", "Download-URL"), | ||
("Author-Email", "Author-email"), | ||
("Maintainer-Email", "Maintainer-email"), | ||
("Project-Url", "Project-URL"), | ||
], | ||
) |
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