fix: update MySQL logic to use 0 for non-pinned posts instead of NULL#47
Merged
Alam-2U merged 1 commit intorelease-ulmofrom May 6, 2026
Merged
fix: update MySQL logic to use 0 for non-pinned posts instead of NULL#47Alam-2U merged 1 commit intorelease-ulmofrom
Alam-2U merged 1 commit intorelease-ulmofrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes inconsistent pinned values in the MySQL CommentThread model so newly created non-pinned threads use 0/False instead of NULL, preventing incorrect ordering when sorting by pinned-first.
Changes:
- Make
CommentThread.pinneddefault toFalse(and update MySQL creation logic accordingly). - Update MongoDB→MySQL migration helper to default missing
pinnedvalues toFalse. - Adjust MySQL model test expectations and bump package version.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_backends/test_mysql/test_models.py |
Updates thread creation test to expect pinned=False rather than None. |
forum/migration_helpers.py |
Defaults missing pinned values to False during thread migration/update. |
forum/backends/mysql/models.py |
Changes pinned field to default to False and removes nullable typing/field config. |
forum/backends/mysql/api.py |
Forces pinned=False on MySQL thread creation to avoid NULL inserts. |
forum/__init__.py |
Bumps version to 0.5.8. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
naincy128
approved these changes
May 6, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
After migrating data from MongoDB to MySQL, the
pinnedcolumn in theforum_commentthreadtable had inconsistent values:0(non-pinned) and1(pinned)NULLfor non-pinnedSince sorting prioritizes the
pinnedcolumn beforelast_activity_at, this inconsistency caused incorrect ordering. Non-pinned migrated posts (0) were always appearing above newly created non-pinned posts (NULL), regardless of their recent activity (1 → 0 → NULL).Root Cause
Newly created posts were not assigning a default value to the
pinnedcolumn, resulting inNULLvalues instead of0for non-pinned posts.Changes Made
pinned = 0for non-pinned posts instead ofNULLPost Task
NULLvalues with0pinned TINYINT(1) NOT NULL DEFAULT 0Ticket
COSMO2-902