fix(discover): cast nullable params so Postgres can infer type

The discover @Query used the `(:param is null or col >= :param)` idiom.
For the timestamp (publishedAfter) and numeric (minRatio) params, Postgres
threw "could not determine data type of parameter $1" because the bare
`$1 is null` placeholder is untyped — returning HTTP 500 and breaking the
whole /discover page. (The search() query survives because its nullable
params are only bigint/varchar, which Postgres can null-type.) Wrap the
two problematic params in cast(... as timestamp/big_decimal) in the
is-null check so the type is explicit. ORDER BY ... nulls last / fetch
first were never the problem.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
hehihoho3@gmail.com 2026-05-31 09:56:28 +09:00
parent 632a2d4f8a
commit 152dc0bae4

View File

@ -55,8 +55,8 @@ public interface ChannelVideoRepository extends JpaRepository<ChannelVideo, Long
*/ */
@Query("select v from ChannelVideo v where " @Query("select v from ChannelVideo v where "
+ "v.interestStatus <> 'EXCLUDED' and " + "v.interestStatus <> 'EXCLUDED' and "
+ "(:publishedAfter is null or v.publishedAt >= :publishedAfter) and " + "(cast(:publishedAfter as timestamp) is null or v.publishedAt >= :publishedAfter) and "
+ "(:minRatio is null or v.viewsPerSubRatio >= :minRatio) and " + "(cast(:minRatio as big_decimal) is null or v.viewsPerSubRatio >= :minRatio) and "
+ "(:source is null or v.source = :source) and " + "(:source is null or v.source = :source) and "
+ "(:shortsOnly = false or v.isShorts = true) and " + "(:shortsOnly = false or v.isShorts = true) and "
+ "(:unprocessedOnly = false or v.interestStatus in ('NEW','REVIEWING'))") + "(:unprocessedOnly = false or v.interestStatus in ('NEW','REVIEWING'))")