fix: avoid null bytea in audit search JPQL
All checks were successful
CI / build (push) Successful in 51s
CI / docker (push) Successful in 32s

Hibernate binds null String params as bytea, causing PostgreSQL
lower(bytea) error. Convert null search to empty string in service
layer, use empty-string check in JPQL instead of IS NULL.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-10 13:26:18 +02:00
parent 247ec030e5
commit 0d47c2ec7c
2 changed files with 5 additions and 4 deletions

View File

@@ -25,9 +25,9 @@ public interface AuditRepository extends JpaRepository<AuditEntity, UUID> {
AND (:result IS NULL OR a.result = :result)
AND (:from IS NULL OR a.createdAt >= :from)
AND (:to IS NULL OR a.createdAt <= :to)
AND (:search IS NULL
OR LOWER(a.actorEmail) LIKE LOWER(CONCAT('%', COALESCE(:search, ''), '%'))
OR LOWER(a.resource) LIKE LOWER(CONCAT('%', COALESCE(:search, ''), '%')))
AND (:search = ''
OR LOWER(a.actorEmail) LIKE LOWER(CONCAT('%', :search, '%'))
OR LOWER(a.resource) LIKE LOWER(CONCAT('%', :search, '%')))
ORDER BY a.createdAt DESC
""")
Page<AuditEntity> findFiltered(

View File

@@ -37,6 +37,7 @@ public class AuditService {
public Page<AuditEntity> search(UUID tenantId, String action, String result,
Instant from, Instant to, String search,
Pageable pageable) {
return auditRepository.findFiltered(tenantId, action, result, from, to, search, pageable);
String safeSearch = (search != null && !search.isBlank()) ? search.trim() : "";
return auditRepository.findFiltered(tenantId, action, result, from, to, safeSearch, pageable);
}
}