Skip to content

Commit 14b61ca

Browse files
committed
noticket: FIX: RelPredicate.negate() returned LegacyRelPredicate by mistake + Update tests of YqlPredicate
1 parent d984fc9 commit 14b61ca

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

repository-ydb-v2/src/main/java/tech/ydb/yoj/repository/ydb/yql/YqlPredicate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ public List<YqlPredicateParam<?>> paramList() {
470470

471471
@Override
472472
public YqlPredicate negate() {
473-
return new LegacyRelPredicate<>(this.rel.negate(), this.fieldPath, this.param);
473+
return new RelPredicate<>(this.rel.negate(), this.fieldPath, this.param);
474474
}
475475

476476
@Override

repository-ydb-v2/src/test/java/tech/ydb/yoj/repository/ydb/YqlPredicateTest.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.eq;
1616
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.gt;
1717
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.gte;
18-
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.likeIgnoreCase;
1918
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.in;
2019
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.like;
20+
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.likeIgnoreCase;
2121
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.lt;
2222
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.lte;
2323
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.neq;
2424
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.not;
25-
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.notLikeIgnoreCase;
2625
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.notLike;
26+
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.notLikeIgnoreCase;
2727
import static tech.ydb.yoj.repository.ydb.yql.YqlPredicate.where;
2828

2929
public class YqlPredicateTest {
@@ -340,18 +340,35 @@ public void in_negate() {
340340
assertThat(pred.toYql(schema)).isEqualToIgnoringCase("`status` NOT IN ?");
341341
}
342342

343+
@Test
344+
public void inComplex_single() {
345+
// id IN (('vla', 42)) <=> (id_zone, id_localId) = ('vla', 42)
346+
YqlPredicate pred = where("id").in(new FakeComplexEntity.Id("vla", 42));
347+
348+
assertThat(pred.toYql(complexSchema)).isEqualToIgnoringCase("(`id_zone`, `id_localId`) = ?");
349+
}
350+
351+
@Test
352+
public void inComplex_single_negate() {
353+
// id NOT IN (('vla', 42)) <=> (id_zone, id_localId) <> ('vla', 42)
354+
YqlPredicate pred = where("id").in(new FakeComplexEntity.Id("vla", 42))
355+
.negate();
356+
357+
assertThat(pred.toYql(complexSchema)).isEqualToIgnoringCase("(`id_zone`, `id_localId`) <> ?");
358+
}
359+
343360
@Test
344361
public void inComplex() {
345-
// id IN ('vla', 42)
346-
YqlPredicate pred = where("id").in(new YqlPredicateTest.FakeComplexEntity.Id("vla", 42));
362+
// id IN (('vla', 42), ('man', 35))
363+
YqlPredicate pred = where("id").in(new FakeComplexEntity.Id("vla", 42), new FakeComplexEntity.Id("man", 35));
347364

348365
assertThat(pred.toYql(complexSchema)).isEqualToIgnoringCase("(`id_zone`, `id_localId`) IN ?");
349366
}
350367

351368
@Test
352369
public void inComplex_negate() {
353-
// id NOT IN ('vla', 42)
354-
YqlPredicate pred = where("id").in(new YqlPredicateTest.FakeComplexEntity.Id("vla", 42))
370+
// id NOT IN (('vla', 42), ('man', 35)
371+
YqlPredicate pred = where("id").in(new FakeComplexEntity.Id("vla", 42), new FakeComplexEntity.Id("man", 35))
355372
.negate();
356373

357374
assertThat(pred.toYql(complexSchema)).isEqualToIgnoringCase("(`id_zone`, `id_localId`) NOT IN ?");

0 commit comments

Comments
 (0)