fix: cast the nullable uuid so Postgres can type the existence check

createTopic answered 500: 'could not determine data type of parameter $2'.
The uniqueness check reads

  WHERE normalized_name = :name AND (:except IS NULL OR id <> :except)

and on a create there is no id to exclude, so :except is null. Postgres infers
a parameter's type from how it is used, and `IS NULL` tells it nothing — with
the other use behind an OR it never gets a second chance.

Casting both uses to uuid gives it the type without changing the predicate.

Project creation passed the same code path only because it never reaches
slugTaken: a draft opens with no slug, so the check is skipped. The topic path
runs it on every create.
This commit is contained in:
DongHyeonka
2026-08-21 00:06:40 +09:00
parent 0da7c7e2db
commit 48517b9e65
2 changed files with 3 additions and 3 deletions
@@ -216,7 +216,7 @@ public class JdbcProjectRepositoryAdapter implements ProjectRepositoryPort {
jdbcClient
.sql(
"SELECT EXISTS (SELECT 1 FROM project WHERE slug = :slug"
+ " AND (:except IS NULL OR id <> :except))")
+ " AND (CAST(:except AS uuid) IS NULL OR id <> CAST(:except AS uuid)))")
.param("slug", slug)
.param("except", exceptId)
.query(Boolean.class)
@@ -143,7 +143,7 @@ public class JdbcTopicRepositoryAdapter implements TopicRepositoryPort {
jdbcClient
.sql(
"SELECT EXISTS (SELECT 1 FROM topic WHERE normalized_name = :name"
+ " AND (:except IS NULL OR id <> :except))")
+ " AND (CAST(:except AS uuid) IS NULL OR id <> CAST(:except AS uuid)))")
.param("name", normalizedName)
.param("except", exceptId)
.query(Boolean.class)
@@ -156,7 +156,7 @@ public class JdbcTopicRepositoryAdapter implements TopicRepositoryPort {
jdbcClient
.sql(
"SELECT EXISTS (SELECT 1 FROM topic WHERE slug = :slug"
+ " AND (:except IS NULL OR id <> :except))")
+ " AND (CAST(:except AS uuid) IS NULL OR id <> CAST(:except AS uuid)))")
.param("slug", slug)
.param("except", exceptId)
.query(Boolean.class)