提交 f587a6e4 编写于 作者: N Nikita Koksharov

Fixed - Conditions.in() doesn't work if defined in Conditions.and() #3637

上级 1a20d614
......@@ -103,7 +103,11 @@ public class LiveObjectSearch {
if (ids.isEmpty()) {
return Collections.emptySet();
}
allIds.retainAll(ids);
if (!allIds.isEmpty()) {
allIds.retainAll(ids);
} else {
allIds.addAll(ids);
}
if (allIds.isEmpty()) {
return Collections.emptySet();
}
......
......@@ -359,6 +359,39 @@ public class RedissonLiveObjectServiceTest extends BaseTest {
}
}
@Test
public void testFindIn() {
RLiveObjectService s = redisson.getLiveObjectService();
TestIndexed t1 = new TestIndexed("1");
t1.setNum1(1);
t1.setName1("common");
t1.setName2("value1");
t1 = s.persist(t1);
TestIndexed t2 = new TestIndexed("2");
t2.setNum1(1);
t2.setName1("common");
t2.setName2("value2");
t2 = s.persist(t2);
TestIndexed t3 = new TestIndexed("3");
t3.setNum1(1);
t3.setName1("common");
t3.setName2("value3");
t3 = s.persist(t3);
RScoredSortedSet<Object> t = redisson.getScoredSortedSet("redisson_live_object_index:{org.redisson.RedissonLiveObjectServiceTest$TestIndexed}:num2");
assertThat(t).hasSize(3);
Collection<TestIndexed> objects2 = s.find(TestIndexed.class, Conditions.and(
Conditions.in("num1", 1, 2),
Conditions.in("name2", "value1", "value2")));
assertThat(objects2).hasSize(2);
for (TestIndexed testIndexed : objects2) {
assertThat(testIndexed.getId()).isIn("1", "2");
}
}
@Test
public void testFindEq2() {
RLiveObjectService s = redisson.getLiveObjectService();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册