Fix null check in text search

This commit is contained in:
Andrii Shvaika 2023-10-30 14:00:53 +02:00
parent bf27927a2f
commit fc63257369

View File

@ -41,19 +41,19 @@ public interface WidgetsBundleRepository extends JpaRepository<WidgetsBundleEnti
@Query(nativeQuery = true,
value = "SELECT * FROM widgets_bundle wb WHERE wb.tenant_id = :systemTenantId " +
"AND (wb.title ILIKE CONCAT('%', :textSearch, '%') " +
"AND (:textSearch IS NULL OR wb.title ILIKE CONCAT('%', :textSearch, '%') " +
"OR wb.description ILIKE CONCAT('%', :textSearch, '%') " +
"OR wb.id in (SELECT wbw.widgets_bundle_id FROM widgets_bundle_widget wbw, widget_type wtd " +
"WHERE wtd.id = wbw.widget_type_id " +
"AND (wtd.name ILIKE CONCAT('%', :textSearch, '%') " +
"AND (:textSearch IS NULL OR wtd.name ILIKE CONCAT('%', :textSearch, '%') " +
"OR wtd.description ILIKE CONCAT('%', :textSearch, '%') " +
"OR lower(wtd.tags\\:\\:text)\\:\\:text[] && string_to_array(lower(:textSearch), ' '))))",
countQuery = "SELECT count(*) FROM widgets_bundle wb WHERE wb.tenant_id = :systemTenantId " +
"AND (wb.title ILIKE CONCAT('%', :textSearch, '%') " +
"AND (:textSearch IS NULL OR wb.title ILIKE CONCAT('%', :textSearch, '%') " +
"OR wb.description ILIKE CONCAT('%', :textSearch, '%') " +
"OR wb.id in (SELECT wbw.widgets_bundle_id FROM widgets_bundle_widget wbw, widget_type wtd " +
"WHERE wtd.id = wbw.widget_type_id " +
"AND (wtd.name ILIKE CONCAT('%', :textSearch, '%') " +
"AND (:textSearch IS NULL OR wtd.name ILIKE CONCAT('%', :textSearch, '%') " +
"OR wtd.description ILIKE CONCAT('%', :textSearch, '%') " +
"OR lower(wtd.tags\\:\\:text)\\:\\:text[] && string_to_array(lower(:textSearch), ' '))))"
)
@ -75,19 +75,19 @@ public interface WidgetsBundleRepository extends JpaRepository<WidgetsBundleEnti
@Query(nativeQuery = true,
value = "SELECT * FROM widgets_bundle wb WHERE wb.tenant_id IN (:tenantIds) " +
"AND (wb.title ILIKE CONCAT('%', :textSearch, '%') " +
"AND (:textSearch IS NULL OR wb.title ILIKE CONCAT('%', :textSearch, '%') " +
"OR wb.description ILIKE CONCAT('%', :textSearch, '%') " +
"OR wb.id in (SELECT wbw.widgets_bundle_id FROM widgets_bundle_widget wbw, widget_type wtd " +
"WHERE wtd.id = wbw.widget_type_id " +
"AND (wtd.name ILIKE CONCAT('%', :textSearch, '%') " +
"AND (:textSearch IS NULL OR wtd.name ILIKE CONCAT('%', :textSearch, '%') " +
"OR wtd.description ILIKE CONCAT('%', :textSearch, '%') " +
"OR lower(wtd.tags\\:\\:text)\\:\\:text[] && string_to_array(lower(:textSearch), ' '))))",
countQuery = "SELECT count(*) FROM widgets_bundle wb WHERE wb.tenant_id IN (:tenantIds) " +
"AND (wb.title ILIKE CONCAT('%', :textSearch, '%') " +
"AND (:textSearch IS NULL OR wb.title ILIKE CONCAT('%', :textSearch, '%') " +
"OR wb.description ILIKE CONCAT('%', :textSearch, '%') " +
"OR wb.id in (SELECT wbw.widgets_bundle_id FROM widgets_bundle_widget wbw, widget_type wtd " +
"WHERE wtd.id = wbw.widget_type_id " +
"AND (wtd.name ILIKE CONCAT('%', :textSearch, '%') " +
"AND (:textSearch IS NULL OR wtd.name ILIKE CONCAT('%', :textSearch, '%') " +
"OR wtd.description ILIKE CONCAT('%', :textSearch, '%') " +
"OR lower(wtd.tags\\:\\:text)\\:\\:text[] && string_to_array(lower(:textSearch), ' '))))"
)