Browse Source
Merge pull request #9560 from dashevchenko/ilikeFix
Fixed ilike syntax for native query
pull/9571/head
Andrew Shvayka
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
3 additions and
1 deletions
-
application/src/test/java/org/thingsboard/server/service/notification/NotificationTargetApiTest.java
-
dao/src/main/java/org/thingsboard/server/dao/sql/notification/NotificationTargetRepository.java
|
|
|
@ -24,6 +24,7 @@ import org.springframework.test.web.servlet.ResultMatcher; |
|
|
|
import org.thingsboard.server.common.data.User; |
|
|
|
import org.thingsboard.server.common.data.id.TenantId; |
|
|
|
import org.thingsboard.server.common.data.notification.NotificationDeliveryMethod; |
|
|
|
import org.thingsboard.server.common.data.notification.NotificationType; |
|
|
|
import org.thingsboard.server.common.data.notification.rule.trigger.config.EntityActionNotificationRuleTriggerConfig; |
|
|
|
import org.thingsboard.server.common.data.notification.targets.NotificationTarget; |
|
|
|
import org.thingsboard.server.common.data.notification.targets.platform.AllUsersFilter; |
|
|
|
@ -144,6 +145,7 @@ public class NotificationTargetApiTest extends AbstractNotificationApiTest { |
|
|
|
notificationTarget.setConfiguration(targetConfig); |
|
|
|
save(notificationTarget, status().isOk()); |
|
|
|
assertThat(notificationTargetDao.findByTenantIdAndPageLink(differentTenantId, new PageLink(10)).getData()).isNotEmpty(); |
|
|
|
assertThat(notificationTargetDao.findByTenantIdAndSupportedNotificationTypeAndPageLink(differentTenantId, NotificationType.GENERAL, new PageLink(10)).getData()).isNotEmpty(); |
|
|
|
|
|
|
|
deleteDifferentTenant(); |
|
|
|
assertThat(notificationTargetDao.findByTenantIdAndPageLink(differentTenantId, new PageLink(10)).getData()).isEmpty(); |
|
|
|
|
|
|
|
@ -39,7 +39,7 @@ public interface NotificationTargetRepository extends JpaRepository<Notification |
|
|
|
Pageable pageable); |
|
|
|
|
|
|
|
@Query(value = "SELECT * FROM notification_target t WHERE t.tenant_id = :tenantId " + |
|
|
|
"AND (:searchText IS NULL OR ilike(t.name, concat('%', :searchText, '%')) = true) " + |
|
|
|
"AND (:searchText IS NULL OR t.name ILIKE concat('%', :searchText, '%')) " + |
|
|
|
"AND (cast(t.configuration as json) ->> 'type' <> 'PLATFORM_USERS' OR " + |
|
|
|
"cast(t.configuration as json) -> 'usersFilter' ->> 'type' IN :usersFilterTypes)", nativeQuery = true) |
|
|
|
Page<NotificationTargetEntity> findByTenantIdAndSearchTextAndUsersFilterTypeIfPresent(@Param("tenantId") UUID tenantId, |
|
|
|
|