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:
+1
-1
@@ -216,7 +216,7 @@ public class JdbcProjectRepositoryAdapter implements ProjectRepositoryPort {
|
|||||||
jdbcClient
|
jdbcClient
|
||||||
.sql(
|
.sql(
|
||||||
"SELECT EXISTS (SELECT 1 FROM project WHERE slug = :slug"
|
"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("slug", slug)
|
||||||
.param("except", exceptId)
|
.param("except", exceptId)
|
||||||
.query(Boolean.class)
|
.query(Boolean.class)
|
||||||
|
|||||||
+2
-2
@@ -143,7 +143,7 @@ public class JdbcTopicRepositoryAdapter implements TopicRepositoryPort {
|
|||||||
jdbcClient
|
jdbcClient
|
||||||
.sql(
|
.sql(
|
||||||
"SELECT EXISTS (SELECT 1 FROM topic WHERE normalized_name = :name"
|
"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("name", normalizedName)
|
||||||
.param("except", exceptId)
|
.param("except", exceptId)
|
||||||
.query(Boolean.class)
|
.query(Boolean.class)
|
||||||
@@ -156,7 +156,7 @@ public class JdbcTopicRepositoryAdapter implements TopicRepositoryPort {
|
|||||||
jdbcClient
|
jdbcClient
|
||||||
.sql(
|
.sql(
|
||||||
"SELECT EXISTS (SELECT 1 FROM topic WHERE slug = :slug"
|
"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("slug", slug)
|
||||||
.param("except", exceptId)
|
.param("except", exceptId)
|
||||||
.query(Boolean.class)
|
.query(Boolean.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user