From 48517b9e65f816155135bb36eb5c650e4cd05240 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 21 Aug 2026 00:06:40 +0900 Subject: [PATCH] fix: cast the nullable uuid so Postgres can type the existence check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../techlog/management/JdbcProjectRepositoryAdapter.java | 2 +- .../techlog/management/JdbcTopicRepositoryAdapter.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/techlog/management/JdbcProjectRepositoryAdapter.java b/src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/techlog/management/JdbcProjectRepositoryAdapter.java index 1dec277..2da8aad 100644 --- a/src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/techlog/management/JdbcProjectRepositoryAdapter.java +++ b/src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/techlog/management/JdbcProjectRepositoryAdapter.java @@ -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) diff --git a/src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/techlog/management/JdbcTopicRepositoryAdapter.java b/src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/techlog/management/JdbcTopicRepositoryAdapter.java index ce13ac1..647d90a 100644 --- a/src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/techlog/management/JdbcTopicRepositoryAdapter.java +++ b/src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/techlog/management/JdbcTopicRepositoryAdapter.java @@ -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)