Skip to content

fix: prevent type mismatch when deleting empty swimlane (#197)#240

Open
klouds27 wants to merge 2 commits into
taigaio:mainfrom
klouds27:fix/197-delete-empty-swimlane-type-error
Open

fix: prevent type mismatch when deleting empty swimlane (#197)#240
klouds27 wants to merge 2 commits into
taigaio:mainfrom
klouds27:fix/197-delete-empty-swimlane-type-error

Conversation

@klouds27
Copy link
Copy Markdown

Problem

Deleting a swimlane that contains no user stories produces a 500 Internal Server Error:

django.db.utils.ProgrammingError: column "swimlane_id" is of type integer but expression is of type text
LINE 4:                            swimlane_id = tmp.sid

The error originates in update_order_and_swimlane (bulk_update_order.py). When the deleted swimlane is empty, all sid values in the bulk update data can be None. PostgreSQL cannot infer the type of a VALUES column that is entirely NULL and defaults to text, which mismatches the integer swimlane_id column.

Fix

Two changes in update_order_and_swimlane:

  1. Early return when data is empty (no user stories to reorder).
  2. Added template="(%s::integer, %s, %s)" to execute_values so PostgreSQL resolves sid as integer even when all values are NULL.

Fixes #197

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>
Copilot AI review requested due to automatic review settings May 27, 2026 22:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 VALUES update).
  • Added an explicit template for execute_values, including an integer cast for sid.

💡 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Internal Server Errro when trying to delete an empty swimlane

2 participants