Skip to content

Commit c67110b

Browse files
committed
fix36
1 parent 9243a3c commit c67110b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ 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 (CAST(:rangeStart AS timestamp) IS NULL OR CAST(:rangeEnd AS timestamp) IS NULL OR e.eventDate BETWEEN :rangeStart AND :rangeEnd)")
38+
"AND (:rangeStart IS NULL OR e.eventDate >= :rangeStart) " +
39+
"AND (:rangeEnd IS NULL OR e.eventDate <= :rangeEnd)")
3940
@EntityGraph(attributePaths = {"category", "initiator"})
4041
Page<Event> searchEventsAdmin(@Param("users") List<Long> users,
4142
@Param("states") List<EventState> states,
@@ -51,8 +52,8 @@ Page<Event> searchEventsAdmin(@Param("users") List<Long> users,
5152
" LOWER(e.description) LIKE LOWER(CONCAT('%', :text, '%'))) " +
5253
"AND (:categories IS NULL OR e.category.id IN :categories) " +
5354
"AND (:paid IS NULL OR e.paid = :paid) " +
54-
"AND (CAST(:rangeStart AS timestamp) IS NULL OR e.eventDate >= :rangeStart) " +
55-
"AND (CAST(:rangeEnd AS timestamp) IS NULL OR e.eventDate <= :rangeEnd) " +
55+
"AND (:rangeStart IS NULL OR e.eventDate >= :rangeStart) " +
56+
"AND (:rangeEnd IS NULL OR e.eventDate <= :rangeEnd) " +
5657
"ORDER BY e.eventDate")
5758
Page<Event> searchEventsPublic(@Param("text") String text,
5859
@Param("categories") List<Long> categories,

0 commit comments

Comments
 (0)