Skip to content

Commit b015926

Browse files
committed
fix37
1 parent c67110b commit b015926

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

ewm-service/src/main/java/ru/practicum/ewm/event/repository/EventRepository.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public interface EventRepository extends JpaRepository<Event, Long> {
3535
"WHERE (:users IS NULL OR e.initiator.id IN :users) " +
3636
"AND (:states IS NULL OR e.state IN :states) " +
3737
"AND (:categories IS NULL OR e.category.id IN :categories) " +
38-
"AND (:rangeStart IS NULL OR e.eventDate >= :rangeStart) " +
39-
"AND (:rangeEnd IS NULL OR e.eventDate <= :rangeEnd)")
38+
"AND (CAST(:rangeStart AS timestamp) IS NULL OR CAST(:rangeEnd AS timestamp) IS NULL OR e.eventDate BETWEEN :rangeStart AND :rangeEnd)")
4039
@EntityGraph(attributePaths = {"category", "initiator"})
4140
Page<Event> searchEventsAdmin(@Param("users") List<Long> users,
4241
@Param("states") List<EventState> states,
@@ -52,8 +51,8 @@ Page<Event> searchEventsAdmin(@Param("users") List<Long> users,
5251
" LOWER(e.description) LIKE LOWER(CONCAT('%', :text, '%'))) " +
5352
"AND (:categories IS NULL OR e.category.id IN :categories) " +
5453
"AND (:paid IS NULL OR e.paid = :paid) " +
55-
"AND (:rangeStart IS NULL OR e.eventDate >= :rangeStart) " +
56-
"AND (:rangeEnd IS NULL OR e.eventDate <= :rangeEnd) " +
54+
"AND (CAST(:rangeStart AS timestamp) IS NULL OR e.eventDate >= :rangeStart) " +
55+
"AND (CAST(:rangeEnd AS timestamp) IS NULL OR e.eventDate <= :rangeEnd) " +
5756
"ORDER BY e.eventDate")
5857
Page<Event> searchEventsPublic(@Param("text") String text,
5958
@Param("categories") List<Long> categories,

0 commit comments

Comments
 (0)