[PR #2603] [MERGED] fix(project): replace CAST(... AS int) with CASE WHEN for MySQL 8 compat #8394

Closed
opened 2026-04-20 18:11:34 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/2603
Author: @tink-bot
Created: 4/11/2026
Status: Merged
Merged: 4/11/2026
Merged by: @kolaente

Base: mainHead: fix-mysql-cast-int


📝 Commits (3)

  • b53fac6 test(project): pin archived propagation aggregation in ReadAll CTE
  • fc13f40 fix(project): replace CAST(... AS int) with CASE WHEN for MySQL 8 compat
  • b4b837f ci: add tests using mysql-8

📊 Changes

3 files changed (+69 additions, -7 deletions)

View changed files

📝 .github/workflows/test.yml (+21 -5)
📝 pkg/models/project.go (+2 -2)
📝 pkg/models/project_test.go (+46 -0)

📄 Description

MySQL 8 rejects CAST(all_projects.is_archived AS int) in the recursive project CTE (only SIGNED/UNSIGNED/CHAR/... are accepted as target types), so /api/v1/projects, /api/v1/tasks, and /api/v1/labels return HTTP 500 for every authenticated user on v2.3.0. SQLite, Postgres, and MariaDB lax mode silently accept the expression — which is why the mariadb:12 CI matrix leg missed it.

Replace both CAST(... AS int) expressions with MAX(CASE WHEN ... THEN 1 ELSE 0 END), which is dialect-agnostic and needs no cast on any supported backend. Adds a regression subtest in TestProject_ReadAll that pins the archived-propagation semantics (child inherits is_archived from archived parent; getArchived=false filters both out) so future changes can't accidentally reintroduce a non-portable expression.

Fixes #2589


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-vikunja/vikunja/pull/2603 **Author:** [@tink-bot](https://github.com/tink-bot) **Created:** 4/11/2026 **Status:** ✅ Merged **Merged:** 4/11/2026 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `fix-mysql-cast-int` --- ### 📝 Commits (3) - [`b53fac6`](https://github.com/go-vikunja/vikunja/commit/b53fac6a025551d19d9079024b9028a08f20e483) test(project): pin archived propagation aggregation in ReadAll CTE - [`fc13f40`](https://github.com/go-vikunja/vikunja/commit/fc13f4054bf2207737aad5bc2e91d647fd5e41a9) fix(project): replace CAST(... AS int) with CASE WHEN for MySQL 8 compat - [`b4b837f`](https://github.com/go-vikunja/vikunja/commit/b4b837fe0a51fd15ddf8ea225672a9ebb2354ec2) ci: add tests using mysql-8 ### 📊 Changes **3 files changed** (+69 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/test.yml` (+21 -5) 📝 `pkg/models/project.go` (+2 -2) 📝 `pkg/models/project_test.go` (+46 -0) </details> ### 📄 Description MySQL 8 rejects `CAST(all_projects.is_archived AS int)` in the recursive project CTE (only `SIGNED`/`UNSIGNED`/`CHAR`/... are accepted as target types), so `/api/v1/projects`, `/api/v1/tasks`, and `/api/v1/labels` return HTTP 500 for every authenticated user on v2.3.0. SQLite, Postgres, and MariaDB lax mode silently accept the expression — which is why the mariadb:12 CI matrix leg missed it. Replace both `CAST(... AS int)` expressions with `MAX(CASE WHEN ... THEN 1 ELSE 0 END)`, which is dialect-agnostic and needs no cast on any supported backend. Adds a regression subtest in `TestProject_ReadAll` that pins the archived-propagation semantics (child inherits `is_archived` from archived parent; `getArchived=false` filters both out) so future changes can't accidentally reintroduce a non-portable expression. Fixes #2589 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 18:11:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#8394