This repository has been archived by the owner on Jan 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Fix slug overflow in MySQL with strict mode enabled #70
Merged
Conversation
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
Our initial migration test only covered SQLite. We found later that AM17 deployments making use of MySQL in strict mode (the default in recent releases) failed: django.db.utils.DataError: Problem installing fixture '/home/travis/build/artefactual/archivematica-fpr-admin/fpr/migrations/pronom_92.json': Could not load fpr.Format(pk=None): (1406, "Data too long for column 'slug' at row 1") Django's CharField validator doesn't seem to kick in during the migration - I suspect this is not a bug in Django but it django-autoslug's AutoSlugField which subclasses the former.
2580543
to
c37dc8a
Compare
The fixture had some values that could cause an overflow in certains RBDMS like MySQL in strict mode.
Ensure that the custom slug generator function truncates the final value based on the max_length property of the field.
@jrwdunham this is ready for CR! |
jraddaoui
approved these changes
Nov 28, 2017
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.
Awesome!
jrwdunham
approved these changes
Nov 28, 2017
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The issue was originally reported by @scollazo here: artefactual/archivematica#792. It's an error seen in recent versions of MySQL where the strict mode comes enabled by default.
pronom_92.json
(fixes Problem: migration fpr.0015_pronom_92 is invalid archivematica#792)_slug
generators to truncate candidates properly (fixes Problem: migration fpr.0015_pronom_92 is invalid archivematica#792)unique=True
to all the slug fields (fixes Problem: slug field in Format and FormatVersion is not ensuring uniqueness #64)testproject/
And bumped version to 1.7.4.