fix: prevent type mismatch when deleting empty swimlane (#197)#240
Open
klouds27 wants to merge 2 commits into
Open
fix: prevent type mismatch when deleting empty swimlane (#197)#240klouds27 wants to merge 2 commits into
klouds27 wants to merge 2 commits into
Conversation
When deleting a swimlane with no user stories, all swimlane_id values in the bulk update data could be None. PostgreSQL infers text type for a VALUES column that is entirely NULL, causing a DatatypeMismatch error against the integer swimlane_id column. Add an explicit ::integer cast via the template parameter of execute_values so PostgreSQL resolves the correct type regardless of whether sid values are NULL or integer. Also guard against an empty data list to skip the update when there are no user stories to reorder. Fixes taigaio#197 Signed-off-by: klouds27 <adalwolf@gmail.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the bulk order/swimlane update routine to safely handle empty updates and to better control SQL value formatting in the execute_values call.
Changes:
- Added an early return when there is no data to update (prevents running an empty
VALUESupdate). - Added an explicit
templateforexecute_values, including an integer cast forsid.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| WHERE tmp.ussid = userstories_userstory.id""", | ||
| data) | ||
| data, | ||
| template="(%s::integer, %s, %s)") |
Add explicit ::integer casts for ussid and new_order in the execute_values template, matching the types of the target columns (userstories_userstory.id and kanban_order). Makes the query self-documenting and avoids implicit cast reliance. Signed-off-by: klouds27 <adalwolf@gmail.com>
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.
Problem
Deleting a swimlane that contains no user stories produces a 500 Internal Server Error:
The error originates in
update_order_and_swimlane(bulk_update_order.py). When the deleted swimlane is empty, allsidvalues in the bulk update data can beNone. PostgreSQL cannot infer the type of aVALUEScolumn that is entirelyNULLand defaults totext, which mismatches theintegerswimlane_idcolumn.Fix
Two changes in
update_order_and_swimlane:datais empty (no user stories to reorder).template="(%s::integer, %s, %s)"toexecute_valuesso PostgreSQL resolvessidasintegereven when all values areNULL.Fixes #197