mirror of
https://github.com/iflytek/skillhub.git
synced 2026-09-07 08:26:00 +00:00
fix(namespace): type nullable search terms
Signed-off-by: dongmucat <1127093059@qq.com>
This commit is contained in:
parent
f8df616480
commit
0cbe33436d
2 changed files with 18 additions and 4 deletions
|
|
@ -66,6 +66,20 @@ class NamespaceJpaRepositoryTest {
|
|||
.containsExactly("underscore-team");
|
||||
}
|
||||
|
||||
@Test
|
||||
void search_acceptsNullQueryAlongsideOtherFilters() {
|
||||
var page = repository.search(
|
||||
NamespaceStatus.ACTIVE,
|
||||
NamespaceType.TEAM,
|
||||
null,
|
||||
"percent-team",
|
||||
PageRequest.of(0, 1)
|
||||
);
|
||||
|
||||
assertThat(page.getContent()).extracting(Namespace::getSlug)
|
||||
.containsExactly("percent-team");
|
||||
}
|
||||
|
||||
private Namespace persist(Namespace namespace) {
|
||||
entityManager.persist(namespace);
|
||||
return namespace;
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ public interface NamespaceJpaRepository
|
|||
AND (:type IS NULL OR n.type = :type)
|
||||
AND (
|
||||
:query IS NULL
|
||||
OR lower(n.slug) LIKE lower(concat('%', :query, '%')) ESCAPE '!'
|
||||
OR lower(n.displayName) LIKE lower(concat('%', :query, '%')) ESCAPE '!'
|
||||
OR lower(n.slug) LIKE lower(concat('%', cast(:query as string), '%')) ESCAPE '!'
|
||||
OR lower(n.displayName) LIKE lower(concat('%', cast(:query as string), '%')) ESCAPE '!'
|
||||
)
|
||||
AND (:slug IS NULL OR n.slug = :slug)
|
||||
""")
|
||||
|
|
@ -52,8 +52,8 @@ public interface NamespaceJpaRepository
|
|||
AND (:type IS NULL OR n.type = :type)
|
||||
AND (
|
||||
:query IS NULL
|
||||
OR lower(n.slug) LIKE lower(concat('%', :query, '%')) ESCAPE '!'
|
||||
OR lower(n.displayName) LIKE lower(concat('%', :query, '%')) ESCAPE '!'
|
||||
OR lower(n.slug) LIKE lower(concat('%', cast(:query as string), '%')) ESCAPE '!'
|
||||
OR lower(n.displayName) LIKE lower(concat('%', cast(:query as string), '%')) ESCAPE '!'
|
||||
)
|
||||
AND (:slug IS NULL OR n.slug = :slug)
|
||||
""")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue